forked from RichGuk/rrsync
-
Notifications
You must be signed in to change notification settings - Fork 2
Simple rsync backup script written in Ruby
toddb/rrsync
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
rrsyncfolders aka rrsync http://github.com/toddb/rrsync/tree/master This script is a fork on rrsync by RichGuk: http://github.com/RichGuk/rrsync/tree/master This synchronise folders script was written so that I can back up my machine via rsync to two places. One, my flash drive and, two, my remote server. I have two main scenarios: I have files that I need to "synchronise" (two-way) with my flash drive because I add items both to my machine and my flash drive (on other machines). I also want to take straight "backups" (one-way). There is nothing flash in this script and I would have written it without rrsync. Hence forking it. If you want a GUI version there is always Cyberduck (on OSX). What I did notice is that it won't delete files and I need it to. == Main features: - Backup (one-way) and Synchronise (two-way) modes - Multiple backup regimes configurable on the same script - Rake-enabled (and thus can also be run from TextMate) - Easy dry run mode - Logging if you need it - Can extend output type (plain text, html) == How to install A few things are required for this script to function correctly. * Ruby 1.8.x * rsync 3.0.x * ssh command * rrsync configuration Rsync on OS X 10.5: On OS X 10.5 the default rsync is out of date and missing a few used options you may use macports to install the latest. sudo port install rsync To install the script simply copy it to where ever you wish to run the script from. Make sure its executable by issuing the following: sudo chmod 755 rrsync.rb Make sure you then update the configuration file (see below) cp config.sample.rb config.rb vi config.rb [see config options below] If you have IGNORE option: cp IGNORE.sample IGNORE vi IGNORE [add files - any problems see the rsync help] == How to use rake (default: dryrun) rake all = Rake options (rake -T) rake all # Alias for sync:all rake dryrun # Alias for sync:dry [DEFAULT] rake sync:all # Synchronise and backup all folders rake sync:backup # Backup folders rake sync:config # List all folders in the configuration rake sync:dry # Dryrun all folders rake sync:sync # Synchronise folders Hence the configuration file object: == Configuration Options per sync = Mandatory :base => from, to :backup => location1, location2, ... :sync => location1, location2, ... :base => %w(~/Documents/ USB-FLASH/backup/testing), :backup => %w(src home agile-2008), :sync => %w(agile) = Optional (defaults) :logger => nil, [eg UserLogger.new - see below to setup a new Logger] :dryrun => true, :cmd => "rsync -a -u -v" [ie RsyncCmd.new - this allows local folder backups by default] == CONFIG file sample This sample has two regimes. = Regime 1: local - Backup between a folder on the main drive and the USB - one-way back-up for 3 folders (this is a straight backup because, say, I don't do source dev to the USB) - two-way sync for 2 folders (so if you update either the local or the USB both will have a copy) = Regime 2: remote - same as above but it is a straight backup to a remote server (so that if my machine and USB are both stolen I'm still okay - don't laugh it almost happened) = NOTE on private keys You will probably need to make sure that your private key (if used) has the correct perms (chmod 0600) = FINALLY - I load both of these into the CONFIG.opts so that Rake can process them =Sample local = { :base => %w(~/Documents/ USB-DRIVE/backup/), :backup => %w(src home docs), :sync => %w(agile pdfs) } remote = { :base => %w(~/Documents/ /home/.server/user/backup), :backup => %w(src home docs agile pdfs) :cmd => RsyncCmd.new({ :sshuser => 'username', :sshserver => 'myserver.domain.com', :privatekey => '~/.ssh/id_rsa, :rsynopts => RsyncCmd.new().default_backup_remote_opts }) } CONFIG.opts << local << remote == Creating logging to a file To configure logging, pass in a :logger when configuring the backup regime. This logger is based on rrysnc's original approach wrapping a start and stop around the output. Make sure the script has the correct permissions to write to the log file. = Example local = { :base => %w(~/Documents/ USB-DRIVE/backup/), :backup => %w(src home docs), :sync => %w(agile pdfs), :logger => UserLogger.new() } = Options :file => '/var/log/rrsync.log', :age => 'daily', :debug => true, #If true output to screen else output is sent to log file. :silent => false #Total silent = no log or screen output. ============================================================================== == Pitfalls * This is not supported on WINDOWS! I don't think it will work at all! * Only supports SSH as the transfer protocol == Contact/contribute Feel free to fork and send me pull requests I will most likely merge the changes into the main repo. ==============================================================================
About
Simple rsync backup script written in Ruby
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Ruby 100.0%