summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-05-30 00:01:02 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-05-30 00:01:48 +0200
commit7da0e86dd003e6d01771e0422a39d3bb0490437f (patch)
tree8100c0f756340e4cb8c54611e238dd4adb8a5ec6
parentac23671386353371d759608fe8d09c72de78ae02 (diff)
downloadrybackup-7da0e86dd003e6d01771e0422a39d3bb0490437f.tar.xz
rybackup: arg for function arguments, not val
-rwxr-xr-xrybackup.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/rybackup.py b/rybackup.py
index 259dbcd..f78d18f 100755
--- a/rybackup.py
+++ b/rybackup.py
@@ -74,7 +74,7 @@ bin = {
# Functions
#
# Snapshot rotation
-def rotate(val):
+def rotate(arg):
rotation = { # Interval relations
"hourly" : ["hourly", 1, 2],
"daily" : ["hourly", count['hourly'], 1],
@@ -83,26 +83,26 @@ def rotate(val):
}
# Delete the oldest snapshot
- if path.isdir("%s/%s.%s" % (bak['dst'], val, count[val])):
- rmtree("%s/%s.%s" % (bak['dst'], val, count[val]))
+ if path.isdir("%s/%s.%s" % (bak['dst'], arg, count[arg])):
+ rmtree("%s/%s.%s" % (bak['dst'], arg, count[arg]))
# Shift the middle snapshot(s) back by one
- for i in reversed(range(2, count[val]+1)):
- if i-1 == 1 and val == "hourly": break
+ for i in reversed(range(2, count[arg]+1)):
+ if i-1 == 1 and arg == "hourly": break
- if path.isdir("%s/%s.%s" % (bak['dst'], val, i-1)):
- rename("%s/%s.%s" % (bak['dst'], val, i-1),
- "%s/%s.%s" % (bak['dst'], val, i))
+ if path.isdir("%s/%s.%s" % (bak['dst'], arg, i-1)):
+ rename("%s/%s.%s" % (bak['dst'], arg, i-1),
+ "%s/%s.%s" % (bak['dst'], arg, i))
# Make a hard-link-only copy of the latest snapshot
- if path.isdir("%s/%s.%s" % (bak['dst'], rotation[val][0], rotation[val][1])):
- call("%s -al %s/%s.%s %s/%s.%s" % (bin['cp'], bak['dst'], rotation[val][0],
- rotation[val][1], bak['dst'], val,
- rotation[val][2]), shell=True)
+ if path.isdir("%s/%s.%s" % (bak['dst'], rotation[arg][0], rotation[arg][1])):
+ call("%s -al %s/%s.%s %s/%s.%s" % (bin['cp'], bak['dst'], rotation[arg][0],
+ rotation[arg][1], bak['dst'], arg,
+ rotation[arg][2]), shell=True)
# Rsync backup synchronization
-def sync(val):
- rsyncmd = ( # Mirroring options:
+def sync(arg):
+ rsyncopt = ( # Mirroring options:
"--archive", # use the archive mode,
"--verbose", # increase verbosity,
"--delete", # delete extraneous files,
@@ -112,16 +112,16 @@ def sync(val):
for i in bak['src']:
# Create directories from source names
- if not path.isdir("%s/%s.1/%s" % (bak['dst'], val, i[1:])):
- makedirs("%s/%s.1/%s" % (bak['dst'], val, i[1:]))
+ if not path.isdir("%s/%s.1/%s" % (bak['dst'], arg, i[1:])):
+ makedirs("%s/%s.1/%s" % (bak['dst'], arg, i[1:]))
# Mirror directories with rsync (auto. unlinks files that changed)
- call("%s %s %s %s/%s.1/%s" % (bin['rsync'], " ".join(rsyncmd),
- i, bak['dst'], val, i[1:]), shell=True)
+ call("%s %s %s %s/%s.1/%s" % (bin['rsync'], " ".join(rsyncopt),
+ i, bak['dst'], arg, i[1:]), shell=True)
# Make the backup reflect the snapshot time
- if path.isdir("%s/%s.1" % (bak['dst'], val)):
- call("%s %s/%s.1" % (bin['touch'], bak['dst'], val), shell=True)
+ if path.isdir("%s/%s.1" % (bak['dst'], arg)):
+ call("%s %s/%s.1" % (bin['touch'], bak['dst'], arg), shell=True)
# Managing mount points