Permalink
Browse files

updated the script to use rsync and also put the entire backup in a t…

…ar file
  • Loading branch information...
Jason Draper
Jason Draper committed Nov 30, 2010
1 parent fff7956 commit 6103e74523eacd4026cd7079b04c602f205995c1
Showing with 39 additions and 18 deletions.
  1. +2 −2 backup_config.rb
  2. +19 −12 backup_files.rb
  3. +2 −3 folderlist.txt
  4. +16 −1 full_backup.rb
View
@@ -5,7 +5,7 @@
#This is the directory that you want your backups to be placed in
#Sub directories for the date will be created within this directory
-BACKUP_LOCATION = "/home/draper/backups"
+BACKUP_LOCATION = "/Users/gdraper/backups"
#Unless you rename these files, you should not have to change these variables
SQL_SCRIPT = 'backup_all_sql_dbs.rb'
@@ -18,7 +18,7 @@
#Change this to 0 if you do not want to backup MySQL
-BACKUP_MYSQL = 1
+BACKUP_MYSQL = 2
#DB USER NAME AND PASSWORD
#In order for the db backup to work properly, this must be a user that can access all the dbs
View
@@ -3,6 +3,7 @@
#the variables name folders comes from that file
#To add locations to be backed up, please consult that files
require 'backup_config.rb'
+
folders = Array.new
File.open(FOLDER_LIST, "r") do |infile|
@@ -12,7 +13,6 @@
end
end
-
#Get times starting with current time
NOW = Time.now.strftime("%m_%d_%Y")
@@ -27,15 +27,22 @@
folders.each do |f|
- temp_f = f
- tar_file_name = temp_f.reverse.chop
- tar_file_name = temp_f.reverse
- tar_file_name = temp_f.split("/").join("_")
- tar_file_name.chomp!
- tar_file_name = tar_file_name + ".tar.gz"
- tar_file_name = FULL_FOLDER_NAME+"/"+tar_file_name
- puts "Creating tar file: #{tar_file_name} for folder #{f}"
- command = "tar -czf #{tar_file_name} #{f}"
- puts command
- system(command)
+# temp_f = f
+# tar_file_name = temp_f.reverse.chop
+# tar_file_name = temp_f.reverse
+# tar_file_name = temp_f.split("/").join("_")
+# tar_file_name.chomp!
+# tar_file_name = tar_file_name + ".tar.gz"
+# tar_file_name = FULL_FOLDER_NAME+"/"+tar_file_name
+# puts "Creating tar file: #{tar_file_name} for folder #{f}"
+# command = "tar -czf #{tar_file_name} #{f}"
+# puts command
+# system(command)
+backup_folder_name = f.gsub("/","_")
+mkdir_command = "mkdir #{FULL_FOLDER_NAME}/#{backup_folder_name}"
+puts mkdir_command
+system(mkdir_command)
+rsync_command = "rsync -av #{f.chomp}/ #{FULL_FOLDER_NAME}/#{backup_folder_name.chomp}/"
+puts rsync_command
+system(rsync_command)
end
View
@@ -1,3 +1,2 @@
-/home/draper/
-/var/www
-
+/Users/gdraper/Dropbox/code/php
+/Users/gdraper/Dropbox/code/perl
View
@@ -15,9 +15,24 @@
system(command)
end
-puts 'Backup up folders'
+puts 'Backup folders'
command = "ruby #{FOLDER_SCRIPT}"
system(command)
+
+
+#if the user wants a tar file, do it now
+
+NOW = Time.now.strftime("%m_%d_%Y")
+NOW_WITH_TIME = Time.now.strftime("%m_%d_%Y_%H_%M_%S")
+FOLDERNAME = "backup_#{NOW}"
+
+#we need to tar up the file
+tar_command = "cd #{BACKUP_LOCATION} && tar -czf #{FOLDERNAME}.tar.gz #{FOLDERNAME} && rm -rf #{FOLDERNAME}"
+puts tar_command
+system(tar_command)
+
+
+
puts "Full backup complete, all files were stored in #{BACKUP_LOCATION}"

0 comments on commit 6103e74

Please sign in to comment.