Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
790a73ed
Commit
790a73ed
authored
Oct 03, 2011
by
Enrique García Cota
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started making backup changes
parent
b2ef122d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
Rakefile
backup/Rakefile
+18
-13
No files found.
backup/Rakefile
View file @
790a73ed
...
@@ -40,11 +40,11 @@ require 'rake'
...
@@ -40,11 +40,11 @@ require 'rake'
# =========== CUSTOMIZABLE SETTINGS =============
# =========== CUSTOMIZABLE SETTINGS =============
# Environment being used. Can be either 'production' or 'staging'
# Environment being used. Can be either 'production' or 'staging'
ENVIRONMENT
=
'
production
'
ENVIRONMENT
=
'
staging
'
# States where the backups will be stored.
# States where the backups will be stored.
# LOCAL_BACKUP_PATH is only used here, so it can be ignored if required.
# LOCAL_BACKUP_PATH is only used here, so it can be ignored if required.
LOCAL_BACKUP_PATH
=
'/home/
fjuan
/backup'
LOCAL_BACKUP_PATH
=
'/home/
kikito
/backup'
LOCAL_SVNLIST_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/svn_list.txt"
LOCAL_SVNLIST_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/svn_list.txt"
LOCAL_GITLIST_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/git_list.txt"
LOCAL_GITLIST_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/git_list.txt"
LOCAL_REPOSITORY_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/svn"
LOCAL_REPOSITORY_PATH
=
"
#{
LOCAL_BACKUP_PATH
}
/svn"
...
@@ -109,22 +109,27 @@ def repository_exists?(repository)
...
@@ -109,22 +109,27 @@ def repository_exists?(repository)
local_repository_list
.
include?
repository
local_repository_list
.
include?
repository
end
end
def
shell
(
command
)
sh
command
end
def
init_repository
(
repository
)
def
init_repository
(
repository
)
log
"Initializing repository
#{
repository
}
"
,
2
log
"Initializing repository
#{
repository
}
"
,
2
path
=
File
.
join
(
LOCAL_REPOSITORY_PATH
,
repository
)
path
=
File
.
join
(
LOCAL_REPOSITORY_PATH
,
repository
)
pre_file_path
=
"
#{
path
}
/hooks/pre-revprop-change"
pre_file_path
=
"
#{
path
}
/hooks/pre-revprop-change"
sh
"svnadmin create
#{
path
}
"
sh
ell
"svnadmin create
#{
path
}
"
sh
"echo '#!/bin/sh' >
#{
pre_file_path
}
"
sh
ell
"echo '#!/bin/sh' >
#{
pre_file_path
}
"
sh
"chmod +x
#{
pre_file_path
}
"
sh
ell
"chmod +x
#{
pre_file_path
}
"
sh
"svnsync init file://
#{
path
}
#{
remote_repository_url
(
repository
)
}
"
sh
ell
"svnsync init file://
#{
path
}
#{
remote_repository_url
(
repository
)
}
"
end
end
def
sync_repository
(
repository
)
def
sync_repository
(
repository
)
log
"Syncing repository
#{
repository
}
"
,
2
log
"Syncing repository
#{
repository
}
"
,
2
path
=
File
.
join
(
LOCAL_REPOSITORY_PATH
,
repository
)
path
=
File
.
join
(
LOCAL_REPOSITORY_PATH
,
repository
)
sh
"svnsync sync file://
#{
path
}
"
sh
ell
"svnsync sync file://
#{
path
}
"
end
end
def
local_git_list
def
local_git_list
...
@@ -138,17 +143,17 @@ end
...
@@ -138,17 +143,17 @@ end
def
init_git_repository
(
repository
)
def
init_git_repository
(
repository
)
log
"Initializing git repository
#{
repository
}
"
,
2
log
"Initializing git repository
#{
repository
}
"
,
2
path
=
File
.
join
(
LOCAL_GIT_PATH
)
path
=
File
.
join
(
LOCAL_GIT_PATH
)
sh
"cd
#{
path
}
&& git clone
#{
repository
}
"
sh
ell
"cd
#{
path
}
&& git clone
#{
repository
}
"
end
end
def
sync_git_repository
(
repository
)
def
sync_git_repository
(
repository
)
log
"Syncing repository
#{
repository
}
"
,
2
log
"Syncing repository
#{
repository
}
"
,
2
path
=
File
.
join
(
LOCAL_GIT_PATH
,
repository
)
path
=
File
.
join
(
LOCAL_GIT_PATH
,
repository
)
sh
"cd
#{
path
}
&& git pull"
sh
ell
"cd
#{
path
}
&& git pull"
end
end
def
rdiff_get
(
source
,
destination
)
def
rdiff_get
(
source
,
destination
)
sh
"rdiff-backup
#{
ssh_user
}
@
#{
ssh_alias
}
::
#{
source
}
#{
destination
}
"
sh
ell
"rdiff-backup
#{
ssh_user
}
@
#{
ssh_alias
}
::
#{
source
}
#{
destination
}
"
end
end
namespace
:backup
do
namespace
:backup
do
...
@@ -157,14 +162,14 @@ namespace :backup do
...
@@ -157,14 +162,14 @@ namespace :backup do
task
:prepare_folders
do
task
:prepare_folders
do
log
"Preparing local folders"
log
"Preparing local folders"
[
LOCAL_REPOSITORY_PATH
,
LOCAL_GIT_PATH
,
LOCAL_DB_PATH
,
LOCAL_FILES_PATH
,
File
.
join
(
LOCAL_SYMPA_PATH
,
'arc'
),
File
.
join
(
LOCAL_SYMPA_PATH
,
'list_data'
)].
each
do
|
path
|
[
LOCAL_REPOSITORY_PATH
,
LOCAL_GIT_PATH
,
LOCAL_DB_PATH
,
LOCAL_FILES_PATH
,
File
.
join
(
LOCAL_SYMPA_PATH
,
'arc'
),
File
.
join
(
LOCAL_SYMPA_PATH
,
'list_data'
)].
each
do
|
path
|
sh
"mkdir -p
#{
path
}
"
sh
ell
"mkdir -p
#{
path
}
"
end
end
end
end
desc
"Implements the svn repositories backup"
desc
"Implements the svn repositories backup"
task
:svn
=>
:prepare_folders
do
task
:svn
=>
:prepare_folders
do
log
"Getting svn list from
#{
server_url
}
"
log
"Getting svn list from
#{
server_url
}
"
sh
"wget -m -nd
#{
server_url
}
/svn_list.txt -O
#{
LOCAL_SVNLIST_PATH
}
"
sh
ell
"wget -m -nd
#{
server_url
}
/svn_list.txt -O
#{
LOCAL_SVNLIST_PATH
}
"
log
"Initializing new SVN repositories and updating existing ones"
log
"Initializing new SVN repositories and updating existing ones"
file
=
File
.
new
(
LOCAL_SVNLIST_PATH
,
"r"
)
file
=
File
.
new
(
LOCAL_SVNLIST_PATH
,
"r"
)
...
@@ -179,7 +184,7 @@ namespace :backup do
...
@@ -179,7 +184,7 @@ namespace :backup do
desc
"Implements the git repositories backup"
desc
"Implements the git repositories backup"
task
:git
=>
:prepare_folders
do
task
:git
=>
:prepare_folders
do
log
"Getting git list from
#{
server_url
}
"
log
"Getting git list from
#{
server_url
}
"
sh
"wget -m -nd
#{
server_url
}
/git_list.txt -O
#{
LOCAL_GITLIST_PATH
}
"
sh
ell
"wget -m -nd
#{
server_url
}
/git_list.txt -O
#{
LOCAL_GITLIST_PATH
}
"
log
"Initializing new GIT repositories and updating existing ones"
log
"Initializing new GIT repositories and updating existing ones"
file
=
File
.
new
(
LOCAL_GITLIST_PATH
,
"r"
)
file
=
File
.
new
(
LOCAL_GITLIST_PATH
,
"r"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment