backupcleaner/README.md

34 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2022-05-31 00:53:43 +03:00
# backupcleaner
2022-05-31 18:16:22 +03:00
## clean-backups.py
2022-05-31 00:55:09 +03:00
Tool to cleanup backup directory with daily, weekly and monthly backups.
2022-07-13 12:00:34 +03:00
This tool removes **everything** in the specified directory (not recursively by default) except files, containing timestamps in the filename that can identified by this tool as fresh backups.
2022-05-31 18:03:19 +03:00
By default, this tool keeps last 7 daily backups, 4 weekly backups (4 last monday backups) and 3 monthly backups (1st day of last 3 months). You can redefine this by command line parameters.
This tool expects timestamps like this: 20220531 (May 31, 2022), but of course, you can redefine this.
2022-05-31 00:55:09 +03:00
2022-05-31 16:07:14 +03:00
```text
2022-07-13 12:00:34 +03:00
usage: clean-backups.py [-h] [-d N] [-w N] [-m N] [-f] [-r] [-t FORMAT] PATH
2022-05-31 00:55:09 +03:00
Cleanup old backups
positional arguments:
2022-07-13 12:00:34 +03:00
PATH directory path
2022-05-31 00:55:09 +03:00
optional arguments:
2022-07-13 12:00:34 +03:00
-h, --help show this help message and exit
-d N, --daily N keep N daily backups, default: 7
-w N, --weekly N keep N weekly backups, default: 4
-m N, --monthly N keep N monthly backups, default: 3
--day-of-week N day of week for weekly backups, 0 for monday, 6 for sunday, default: 0
2022-05-31 13:16:32 +03:00
--day-of-month N day of month for monthly backups, default: 1
2022-07-13 12:00:34 +03:00
-f, --force suppress remove confirmation
-r, --recursive remove files recursively
2022-05-31 16:50:01 +03:00
-t FORMAT, --timestamp-format FORMAT
2022-07-13 12:00:34 +03:00
format of timestamp, default: %Y%m%d
2022-05-31 16:07:14 +03:00
```
2022-05-31 17:47:43 +03:00
For a complete timestamp format description, see the python strftime() documentation: <https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior>