Commit 790a73ed authored by Enrique García Cota's avatar Enrique García Cota

started making backup changes

parent b2ef122d
......@@ -40,11 +40,11 @@ require 'rake'
# =========== CUSTOMIZABLE SETTINGS =============
# Environment being used. Can be either 'production' or 'staging'
ENVIRONMENT = 'production'
ENVIRONMENT = 'staging'
# States where the backups will be stored.
# 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_GITLIST_PATH = "#{LOCAL_BACKUP_PATH}/git_list.txt"
LOCAL_REPOSITORY_PATH = "#{LOCAL_BACKUP_PATH}/svn"
......@@ -109,22 +109,27 @@ def repository_exists?(repository)
local_repository_list.include? repository
end
def shell(command)
sh command
end
def init_repository(repository)
log "Initializing repository #{repository}", 2
path = File.join(LOCAL_REPOSITORY_PATH, repository)
pre_file_path = "#{path}/hooks/pre-revprop-change"
sh "svnadmin create #{path}"
sh "echo '#!/bin/sh' >#{pre_file_path}"
sh "chmod +x #{pre_file_path}"
sh "svnsync init file://#{path} #{remote_repository_url(repository)}"
shell "svnadmin create #{path}"
shell "echo '#!/bin/sh' >#{pre_file_path}"
shell "chmod +x #{pre_file_path}"
shell "svnsync init file://#{path} #{remote_repository_url(repository)}"
end
def sync_repository(repository)
log "Syncing repository #{repository}", 2
path = File.join(LOCAL_REPOSITORY_PATH, repository)
sh "svnsync sync file://#{path}"
shell "svnsync sync file://#{path}"
end
def local_git_list
......@@ -138,17 +143,17 @@ end
def init_git_repository(repository)
log "Initializing git repository #{repository}", 2
path = File.join(LOCAL_GIT_PATH)
sh "cd #{path} && git clone #{repository}"
shell "cd #{path} && git clone #{repository}"
end
def sync_git_repository(repository)
log "Syncing repository #{repository}", 2
path = File.join(LOCAL_GIT_PATH, repository)
sh "cd #{path} && git pull"
shell "cd #{path} && git pull"
end
def rdiff_get(source, destination)
sh "rdiff-backup #{ssh_user}@#{ssh_alias}::#{source} #{destination}"
shell "rdiff-backup #{ssh_user}@#{ssh_alias}::#{source} #{destination}"
end
namespace :backup do
......@@ -157,14 +162,14 @@ namespace :backup do
task :prepare_folders do
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|
sh "mkdir -p #{path}"
shell "mkdir -p #{path}"
end
end
desc "Implements the svn repositories backup"
task :svn => :prepare_folders do
log "Getting svn list from #{server_url}"
sh "wget -m -nd #{server_url}/svn_list.txt -O #{LOCAL_SVNLIST_PATH}"
shell "wget -m -nd #{server_url}/svn_list.txt -O #{LOCAL_SVNLIST_PATH}"
log "Initializing new SVN repositories and updating existing ones"
file = File.new(LOCAL_SVNLIST_PATH, "r")
......@@ -179,7 +184,7 @@ namespace :backup do
desc "Implements the git repositories backup"
task :git => :prepare_folders do
log "Getting git list from #{server_url}"
sh "wget -m -nd #{server_url}/git_list.txt -O #{LOCAL_GITLIST_PATH}"
shell "wget -m -nd #{server_url}/git_list.txt -O #{LOCAL_GITLIST_PATH}"
log "Initializing new GIT repositories and updating existing ones"
file = File.new(LOCAL_GITLIST_PATH, "r")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment