Subject: Removing dated files
To: None <netbsd-users@netbsd.org>
From: Jan Danielsson <jan.m.danielsson@gmail.com>
List: netbsd-users
Date: 01/22/2007 08:12:16
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig1C25FAAB08A1C687B4DD5223
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello all,
I have a bunch of backup archives which are dated:
.
.
.
documents.2006-12-24.tar.bz2.gpg
documents.2006-12-25.tar.bz2.gpg
documents.2006-12-26.tar.bz2.gpg
documents.2006-12-27.tar.bz2.gpg
.
.
.
systemfiles.2006-11-24.tar.bz2.gpg
systemfiles.2006-11-25.tar.bz2.gpg
systemfiles.2006-11-26.tar.bz2.gpg
systemfiles.2006-11-27.tar.bz2.gpg
.
.
.
I would like to remove some (most!) of these files according to a
pattern:
- Keep all backup files which are two weeks (or less) old
- If backups are more than two weeks old, then keep only the latest one
that week.
- If backups are more than two months old, then keep only the latest one
that month.
- If backups are more than two years old, then keep only the latest one
that year.
This feels like something that probably has been done a gazillion
times before. Am I reinventing the wheel if I write a script which
performs this kind of maintenance? All I have to do is use a regexp to
parse the "base name" and dates, build a tree of it all, and then
traverse the trees, clobbering anything that looks "old" and "redundant"
(according to the rules). It seems like quite a simple thing to write,
but not simple enough for me to go ahead and write without asking first.
--=20
Kind regards,
Jan Danielsson
--------------enig1C25FAAB08A1C687B4DD5223
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)
iD8DBQFFtGPWbgs4ia4rq9IRCllzAJ9VvhpNG7vTtmfcVWww2cx5+bsOWgCfRrvM
22dBjatnGmt60yuN/Otn6gI=
=NNEo
-----END PGP SIGNATURE-----
--------------enig1C25FAAB08A1C687B4DD5223--