[TriLUG] Some script help
Igor Partola via TriLUG
trilug at trilug.org
Fri May 8 11:07:19 EDT 2015
+1 for not doing this in bash. While it's of course possible, Python would
be my choice. There you can compare dates as dates, not as sorted strings.
Another approach: use logrotate to do this. I have seen this used
successfully to take backups from MySQL and keeping X number of days' worth
of backups.
Third approach: forget copying "today's file" and copy the latest file. Use
`ls backup_*.tgz | sort | tail -n 1` to get the latest file.
Fourth approach: use rsync and copy everything. Combine with third approach
to first delete the local backups that are older than 7 days.
Igor
More information about the TriLUG
mailing list