NAME¶expire_backups - Intelligently expire old backups
expire_backups [options] <age> [<age> ...]
DESCRIPTION¶The expire_backups command intelligently remove old backups that are no longer needed.
To define what backups you want to keep for how long, you define a number of age ranges. expire_backups ensures that you will have at least one backup in each age range at all times. It will keep exactly as many backups as are required for that and delete any backups that become redundant.
Age ranges are specified by giving a list of range boundaries in terms of backup cycles. Every time you create a new backup, the existing backups age by one cycle.
Example: when expire_backups is called with the age range definition 1 3 7 14 31, it will guarantee that you always have the following backups available:
- A backup that is 0 to 1 cycles old (i.e, the most recent backup)
- A backup that is 1 to 3 cycles old
- A backup that is 3 to 7 cycles old
- A backup that is 7 to 14 cycles old
- A backup that is 14 to 31 cycles old
expire_backups usage is simple. It requires backups to be stored in directories of the form year-month-day_hour:minute:seconds (YYYY-MM-DD_HH:mm:ss) and works on all backups in the current directory. So for the above backup strategy, the correct invocation would be:
expire_backups.py 1 3 7 14 31
When storing your backups on an S3QL file system, you probably want to specify the --use-s3qlrm option as well. This tells expire_backups to use the s3qlrm command to delete directories.
expire_backups uses a "state file" to keep track which backups are how many cycles old (since this cannot be inferred from the dates contained in the directory names). The standard name for this state file is .expire_backups.dat. If this file gets damaged or deleted, expire_backups no longer knows the ages of the backups and refuses to work. In this case you can use the --reconstruct-state option to try to reconstruct the state from the backup dates. However, the accuracy of this reconstruction depends strongly on how rigorous you have been with making backups (it is only completely correct if the time between subsequent backups has always been exactly the same), so it's generally a good idea not to tamper with the state file.
OPTIONS¶The expire_backups command accepts the following options:
- be really quiet
- --log <target>
- Destination for log messages. Specify none for standard output or syslog for the system logging daemon. Anything else will be interpreted as a file name. Log files will be rotated when they reach 1 MiB, and at most 5 old log files will be kept. Default: None
- --debug-modules <modules>
- Activate debugging output from specified modules (use commas to separate multiple modules). Debug messages will be written to the target specified by the --log option.
- Activate debugging output from all S3QL modules. Debug messages will be written to the target specified by the --log option.
- just print program version and exit
- --state <file>
- File to save state information in (default: ".expire_backups.dat")
- Dry run. Just show which backups would be deleted.
- Try to reconstruct a missing state file from backup dates.
- Use s3qlrm command to delete backups.
EXIT CODES¶expire_backups may terminate with the following exit codes:
- Everything went well.
- An unexpected error occured. This may indicate a bug in the program.
- Invalid command line argument or configuration file key.
SEE ALSO¶expire_backups is shipped as part of S3QL, https://github.com/s3ql/s3ql/.
COPYRIGHT¶© 2008 Nikolaus Rath <Nikolaus@rath.org>
|October 23, 2019||3.3.2|