lib/rbackup.rb in rbackup-0.1.8 vs lib/rbackup.rb in rbackup-0.1.9
- old
+ new
@@ -13,11 +13,12 @@
USAGE
attr_accessor :profiles, :yaml
- def initialize(*args)
+ def initialize(reverse, *args)
+ @reverse = reverse
get_yaml
get_profiles(args, @yaml)
end
def get_profiles(input, hash, force=false)
@@ -36,12 +37,12 @@
end
end
end
def get_yaml
- if $TESTING
- config = SPEC + '/fixtures/rbackup.yml'
+ if $rbackup_config
+ config = $rbackup_config
else
config = File.expand_path("~/.rbackup.yml")
end
if File.exists?(config)
@yaml = File.open(config)
@@ -64,10 +65,17 @@
def rsync(profile)
inc1ude = []
exclude = []
destination = profile['destination']
- source = [ profile['source'] ].flatten
+ source = profile['source']
+
+ if @reverse
+ last = source.split('/').last
+ source = source.split('/')[0..-2].join('/')
+ destination = [ destination, '/', last ].join('/')
+ destination, source = source, destination
+ end
options = "--numeric-ids --safe-links -axzSvL"
# --numeric-ids don't map uid/gid values by user/group name
# --safe-links ignore symlinks that point outside the tree
# -a, --archive recursion and preserve almost everything (-rlptgoD)
\ No newline at end of file