It tells me I have bad syntax on the line:
rsync -a --delete #{DIR_DATA}/ #{todays_folder}/
Here's the entire program:
#!/usr/bin/ruby
require 'rubygems'
require 'fileutils'
DIR_DATA="/mnt/apvdbs03/Public"
DIR_BKUP_ROOT="/backs/apvdbs03"
NUMBER_OF_BACKUPS = 7
def remove_last_backup_folder
last_backup_folder = File.join(DIR_BKUP_ROOT, NUMBER_OF_BACKUPS.to_s)
FileUtil.rm_rf last_backup_folder
end
def roll_backup_folders_forward
NUMBER_OF_BACKUPS.downto(0) do |i|
old_backup_folder = File.join(DIR_BKUP_ROOT, (i - 1).to_s)
new_backup_folder = File.join(DIR_BKUP_ROOT, i.to_s)
File.mv old_backup_folder new_backup_folder if File.exist(old_backup_folder)
end
def yesterdays_folder
@yesterdays_folder ||= File.join(DIR_BKUP_ROOT, 1)
end
def todays_folder
@todays_folder ||= File.join(DIR_BKUP_ROOT, 0)
end
def hard_link_yesterdays_folder
`cp -al #{yesterdays_folder} #{todays_folder}`
end
# rm -rf backup.3
remove_last_backup_folder
# mv backup.2 backup.3
# mv backup.1 backup.2
roll_backup_folders_forward
# cp -al backup.0 backup.1
hard_link_yesterdays_folder
# make todays backup
`rsync -a --delete #{DIR_DATA}/ #{todays_folder}/`