Created
September 15, 2012 22:41
-
-
Save cornet/3730177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Incrental rsync backups using rsync's --link-dest | |
# | |
# This requires the 'develop' branch of the backup gem | |
# | |
require 'net/ssh' | |
Backup::Model.new(:test, 'Description for test') do | |
ip = '10.64.160.218' | |
port = '22' | |
username = 'nathan' | |
base_path = '/srv/backup/test' | |
new_backup = DateTime.now.strftime('%Y%m%d%H%M%S') | |
old_backup = 'old' | |
after do |model| | |
Net::SSH.start(ip, username) do |ssh| | |
ssh.exec "rm #{base_path}/#{old_backup} && ln -s #{base_path}/#{new_backup} #{base_path}/#{old_backup}" | |
end | |
end | |
sync_with RSync::Push do |rsync| | |
rsync.ip = ip | |
rsync.port = port | |
rsync.username = username | |
rsync.path = base_path + '/' + new_backup | |
rsync.mirror = true | |
rsync.compress = true | |
rsync.additional_options = ["--link-dest #{base_path}/#{old_backup}"] | |
rsync.directories do |directory| | |
directory.add '/home/nathan/tmp/test' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment