View on GitHub

rsync-backup

versatile rsync based backup scripts with minimal dependencies

Download this project as a .zip file Download this project as a tar.gz file

BACKUP-PURGE


NAME

backup-purge - delete old backup directories

SYNOPSIS

backup-purge

[<OPTION>]... [<PATTERN>=<DAYS>]...

DESCRIPTION

Delete old backup directories based on pattern matching and ages. The default is to keep secondly, minutely, hourly and fake daily backup directories for at most one day, daily and fake weekly backup directories for at least one week, weekly and fake monthly backup directories for at least one month, monthly and fake yearly backup directories for at least one year and yearly backup directories forever (thus the default operands are hourly=0 fake-daily=0 daily=7 fake-weekly=7 weekly=31 fake-monthly=31 monthly=366 fake-yearly=366).

OPTIONS

-f, --force

Purge even while on battery power.

-n, --dry-run

Perform a trial run with no changes made.

-h, --help[=<FORMAT>]

Show this help message and exit.

-V, --version

Show version information and exit.

OPERANDS

<PATTERN>=<DAYS>

Backup directories matching <PATTERN> are deleted if they are over <DAYS> days old.

Special patterns:

yearly

Matches yearly backup directories.

This corresponds the following pattern:

[0-9][0-9][0-9][0-9]

(for <YEAR>).

monthly

Matches monthly backup directories.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9][0-9][0-9]
[0-9][0-9][0-9][0-9]-[0-9][0-9]

(for <YEAR>[-]<MONTH>).

weekly

Matches weekly backup directories.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9]W[0-9][0-9]
[0-9][0-9][0-9][0-9]-W[0-9][0-9]

(for <YEAR>[-]W<WEEK>).

daily

Matches daily backup directories.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
[0-9][0-9][0-9][0-9]W[0-9][0-9][0-9]
[0-9][0-9][0-9][0-9]-W[0-9][0-9]-[0-9]

(for <YEAR>[-]<MONTH>[-]<DAY> and <YEAR>[-]W<WEEK>[-]<DAY>).

hourly

Matches hourly, minutely and secondly backup directories.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9]*
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]*
[0-9][0-9][0-9][0-9]W[0-9][0-9][0-9]T[0-9][0-9]*
[0-9][0-9][0-9][0-9]-W[0-9][0-9]-[0-9]T[0-9][0-9]*

(for
<YEAR>[-]<MONTH>[-]<DAY>T<HOUR>[[:]<MINUTE>[[:]<SECOND>]] and
<YEAR>[-]W<WEEK>[-]<DAY>T<HOUR>[[:]<MINUTE>[[:]<SECOND>]]).

fake-yearly

Matches yearly backup directories if the year is 9999.

This corresponds the pattern 9999.

fake-monthly

Matches monthly backup directories if the month is 99.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9]99
[0-9][0-9][0-9][0-9]-99

(for <YEAR>[-]99).

fake-weekly

Matches weekly backup directories if the week is 99.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9]W99
[0-9][0-9][0-9][0-9]-W99

(for <YEAR>[-]W99).

fake-daily

Matches daily backup directories if the day of a month is 99 or the day of a week is 9.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9][0-9][0-9]99
[0-9][0-9][0-9][0-9]-[0-9][0-9]-99
[0-9][0-9][0-9][0-9]W[0-9][0-9]9
[0-9][0-9][0-9][0-9]-W[0-9][0-9]-9

(for <YEAR>[-]<MONTH>[-]99 and <YEAR>[-]W<WEEK>[-]9).

fake-hourly

Matches hourly, minutely and secondly backup directories if the hour is 99.

This corresponds the following patterns:

[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T99*
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T99*
[0-9][0-9][0-9][0-9]W[0-9][0-9][0-9]T99*
[0-9][0-9][0-9][0-9]-W[0-9][0-9]-[0-9]T99*

(for
<YEAR>[-]<MONTH>[-]<DAY>T99[[:]<MINUTE>[[:]<SECOND>]] and
<YEAR>[-]W<WEEK>[-]<DAY>T99[[:]<MINUTE>[[:]<SECOND>]]).

FILES

./<YEAR>

A yearly backup directory.

./<YEAR>[-]<MONTH>

A monthly backup directory.

./<YEAR>[-]W<WEEK>

A weekly backup directory.

./<YEAR>[-]<MONTH>[-]<DAY>

A daily backup directory.

./<YEAR>[-]W<WEEK>[-]<DAY>

A daily backup directory.

./<YEAR>[-]<MONTH>[-]<DAY>T<HOUR>

An hourly backup directory.

./<YEAR>[-]W<WEEK>[-]<DAY>T<HOUR>

An hourly backup directory.

./<YEAR>[-]<MONTH>[-]<DAY>T<HOUR>[:]<MINUTE>

A minutely backup directory.

./<YEAR>[-]W<WEEK>[-]<DAY>T<HOUR>[:]<MINUTE>

A minutely backup directory.

./<YEAR>[-]<MONTH>[-]<DAY>T<HOUR>[:]<MINUTE>[:]<SECOND>

A secondly backup directory.

./<YEAR>[-]W<WEEK>[-]<DAY>T<HOUR>[:]<MINUTE>[:]<SECOND>

A secondly backup directory.

./conf/purge-list

An optional configuration file containing patterns and ages which override the default ones. The file must contain operand lines having the following form:

<PATTERN>=<DAYS>

Empty lines and comment lines (starting with a "#") are allowed, too. Backup directories matching <PATTERN> are deleted if they are over <DAYS> days old.

./tmp/

A temporary directory to be used for deleting old backup directories.

COPYRIGHT

Copyright © 2010 - 2024 Eero Häkkinen <Eero+rsync-backup@Häkkinen.fi>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

SEE ALSO

backup(1), backup-help(1), backup-mirror(1)

on_ac_power(1)
Home page