On Jun 24, 2008, at 10:08 AM, Binger David wrote:
Here is a remote backup script I've installed here as a three cron
jobs
running at different frequencies. (rsync >=3 required)
So far, it seems to work as intended.
Is there anything we should do to improve this?
Yes there is.
I misunderstood the behavior under the --append-verify flag.
If, as usual when a Durus database that gets packed, the
sending side's file is smaller than the one on the receiving
side, nothing happens. That's not good for backups.
I think we need to use the '--append' flag between packs,
and to just do a straight rsync, without --append or --append-verify,
when a pack has been detected.
#!/usr/bin/env python
"""
Backup remote Durus database.
This assumes that you have configured your system so that
this user can ssh to the remote system without entering a
password.
"""
from commands import getoutput
import sys, os
try:
remote_host, remote_path, local_path = sys.argv[1:]
except:
print("%s <remote_host> <remote_path> <local_path>" % sys.argv[0])
raise SystemExit
local_prepackstat_path = local_path + '.prepackstat'
local_prepackstat = ''
rsync_flag = '--append-verify'
# The default is a full copy.
rsync_flag = ''
if os.path.exists(local_prepackstat_path):
local_prepackstat = open(local_prepackstat_path).read()
remote_prepackstat = getoutput("ssh %s stat -t %s.prepack" %
(remote_host, remote_path))
if local_prepackstat:
if local_prepackstat == remote_prepackstat:
# Take the fast option if we have evidence that a pack has not
happened since the last run.
rsync_flag = '--append'
f = open(local_prepackstat_path, 'w')
f.write(remote_prepackstat)
f.close()
command = 'rsync %s --rsh=ssh %s:%s %s' % (
rsync_flag, remote_host, remote_path, local_path)
#print(command)
os.system(command)
Note that rsync version 3 still has an advantage over earlier versions
because it offers the fastest option of --append without verify.
This might be useful if you need very frequent updates and/or if
your database is too large to verify at that frequency.
_______________________________________________
QP mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp