I need a command that manages automatically the naming of files for backup purposes. For example, I have a file called
test.txt, and sometimes I manually need to update that file calling a bash script that "recalculates"
I usually, before calling that bash script, I manually do a copy of the file with a format like:
cp test.txt test.txt.bk.x
x is the number of the last backup + 1.
I would like to put a command at the beginning of my bash script like:
backup_cp -options_about_backup_filename_format test.txt
that manages automatically the naming of the next backup file. I don't need to obey the current file naming pattern, it could be any sequential format, for example like the log files in
/var/log where the backup n. 1 is always the latest backup, or as the current one, where the backup numbers are in growing order.
It would be awesome if the command could also erase the oldests backups automatically.