Skip to content

Commit d3e7615

Browse files
committed
Bugfix for empty directories on rotate backup first use.
1 parent bab18e1 commit d3e7615

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.pyc
2+
backup.*

Diff for: example.backup

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
BACKUP_BASE=./backupscripts
4+
BACKUP_CONF=$BACKUP_BASE/backup.conf
5+
BACKUP_DIR=$BACKUP_BASE/backup-base
6+
BACKUP_CMD=$BACKUP_BASE/incrbackup.py
7+
BACKUP_SERVER=backup01
8+
BACKUP_USER=root
9+
BACKUP_NS=backup-name
10+
BACKUP_KEEP=90
11+
12+
$BACKUP_CMD --server $BACKUP_SERVER -f $BACKUP_CONF -t $BACKUP_DIR -u $BACKUP_USER -n $BACKUP_NS -k $BACKUP_KEEP

Diff for: rotatebackups.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def main(argv):
191191
# create the backup object and call its backup method
192192
rotback = RotateBackups(keep, store)
193193
rotated_names = rotback.rotate_backups()
194-
print("\n".join(rotated_names))
194+
if (len(rotated_names) > 0):
195+
print("\n".join(rotated_names)
195196

196197
except(Exception):
197198
logging.exception("Rotate backups failed.")
@@ -200,4 +201,4 @@ def main(argv):
200201

201202
# if we are running the script from the command line, run the main function
202203
if __name__ == "__main__":
203-
main(sys.argv[1:])
204+
main(sys.argv[1:])

0 commit comments

Comments
 (0)