backup - renames multiple files to have their timestamp in the filename
backup [ -c ] [ -f ] [ -m ] [ -n ] [ -u ] [ -v ] [ files ]
backup backs up the filenames supplied to copies which include the original file's timestamp in their name.
would create FILE.<timestamp>
If no filenames are given on the command line, filenames will be read via standard input (as 'rename' command does).
If the argument --move (or one of its forms) is given the file will be renamed (the default is to create a copy).
backup --mv FILE
- -m, --mv, --move
Move: move the file instead of copying it.
- -c, --cp, --copy
Copy: (default action so ignored) This is the default because it may be safer to copy a file than go renaming it if it is in use (e.g. a log file) but it will use more disk space!
- -v, --verbose
Verbose: print names of files successfully backed up.
- -n, --no-act
No Action: show what files would have been backed up.
- -f, --force
Force: overwrite existing files.
- -u, --usage, --help
Usage: show usage
No environment variables are used.
John G. Harrison http://www.aotea.org/john/
Copyright (C) 2005, John G. Harrison, all rights reserved.
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
mv(1), perl(1), localtime(3), rename(1)
If the new filename already exists or the file already has the timestamp in its name you'll get an error.
Perhaps timestamp formatting could be specified on the command line (ala date).
The shell script version has two options, --mvtn and --cptn
The --copy option doesn't work on directories, it creates a file then fails.
The --move option works on a directory if the target doesn't already exist. (move would overwrite an empty target dir or fail on a non-empty target dir)
If you find any bugs or have suggestions, please let the me know... (the best contact method is via my website, because this email address gets much too much spam)