Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
personal:portfolio:rsync-python-script [2014/07/26 20:20] antonello created |
personal:portfolio:rsync-python-script [2024/02/12 10:23] (current) antonello Updated to Python3 (just print function). Tested working in Ubuntu 22.04 |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Rsync Python script ====== | ====== Rsync Python script ====== | ||
- | A Python script | + | A Python script |
+ | |||
+ | Of course it needs to be run under cron. | ||
Fur the actual rsync call that is used in this script see [[http:// | Fur the actual rsync call that is used in this script see [[http:// | ||
Line 22: | Line 25: | ||
maxbkps_d = 0 | maxbkps_d = 0 | ||
| | ||
- | print "** INFO: Starting rsync backup of " | + | print("** INFO: Starting rsync backup of " |
| | ||
# If a complete backup for today already exists I remove it as I can't create an incremental of itself.. | # If a complete backup for today already exists I remove it as I can't create an incremental of itself.. | ||
Line 34: | Line 37: | ||
if (parts[0] == bkpsbase): | if (parts[0] == bkpsbase): | ||
if len(parts) != 2: | if len(parts) != 2: | ||
- | print "**** ERROR: There is a problem with a directory starting with bkpsbase but not having the date elements.. (" | + | print("**** ERROR: There is a problem with a directory starting with bkpsbase but not having the date elements.. (" |
else: | else: | ||
de = parts[1].split(' | de = parts[1].split(' | ||
if len(de) != 3: | if len(de) != 3: | ||
- | print "**** ERROR: There is a problem with a directory having a subset of the date elements.. (" | + | print("**** ERROR: There is a problem with a directory having a subset of the date elements.. (" |
else: | else: | ||
# removing old bkps | # removing old bkps | ||
Line 68: | Line 71: | ||
| | ||
if (maxbkps_y == 0): # first backup | if (maxbkps_y == 0): # first backup | ||
- | print "** INFO: Performing first backup of the serie.." | + | print("** INFO: Performing first backup of the serie.." |
bkpcommand2 = "rsync --archive --one-file-system --hard-links " | bkpcommand2 = "rsync --archive --one-file-system --hard-links " | ||
bkpcommand2 += " | bkpcommand2 += " | ||
Line 86: | Line 89: | ||
os.system(bkpcommand3) | os.system(bkpcommand3) | ||
| | ||
- | print "** INFO: rsync backup completed - " | + | print("** INFO: rsync backup completed - " |
+ | ~~DISCUSSION~~ | ||