Creating numbered backup files
Now for a bonus here is a ready-to-run script that can be used to make numbered backup files. Before I came up with this (many years ago) I would go through the ritual of making the backup by hand. My numbering scheme was not always consistent, and I quickly realized it would be easier to have a script do it. This is something computers are really good at.
I call this script cbS
. I wrote this so long ago I'm not even sure what it stands for. Maybe it was Computer Backup Script or something like that.
Chapter 3 – Script 13
#!/bin/sh # echo "cbS by Lewis 5/4/2017" if [ $# -eq 0 ] ; then echo "Usage: cbS filename(s) " echo " Will make a numbered backup of the files(s) given." echo " Files must be in the current directory." exit 255 fi rc=0 # return code, default is no error for fn in $* # for each filename given on the command line do if [ ! -f $fn ] ; then # if not found echo "File $fn not found." rc=1 ...