I wrote a small script to do file-level backup/versioning of a single file or group of files as a whole, without resorting to anything beyond basic cp, tar and rm.
Basically it works like this:
$ versionbackup.sh -h
versionbackup.sh -h -v -b backups | -r retdays [-d dateargs] [-m middlechar] [-p prefixchar]
[-r retention] [-s suffixchar] [-t tarball] file ...
-b numbaks sets the number of backups to keep (copies retention)
-d dateformat a string to be passed verbatim to the date command. Beware!
in this case, if you omit time in a resolution high enough
you could end _overwriting_ files! Example, if you rotate
the files hourly and don't specify an hour in the date string,
but only the day, you'll end up overwriting the same file 23
times a day... better not to use this option if you are not
sure. Note than in this case, -m is ignored.
-m middle sets the middle char
-p prefix sets the prefix char
-r daysago keeps files newer than daysago days (time retention)
-s suffix sets the suffix char
-t tarball creates a tarball of the input files and rotate this instead
for convenience, the tar is automatically .gz compressed
-v verbose, echo every operation, including option parsing
(useful to debug command-line options)
It should work nicely on any variant of unix (tested on linux and MacOSX).
I'll find some place to post the source and link it back here.
2010/09/20
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment