Before updating a system file I'll take a backup copy of it. The less imaginative of you will choose a backup name like
file2. Some of you will use your initials, especially if you work in an environment where you might run into your colleagues working on the same platform. Some of you who are a bit cleverer will incorporate the date in the backup file name. Sure you can see the date from the timestamp on the file but that information can be lost when you copy the file or restore it from an archive.
For files that I might be testing configuration, I might make lots of copies as I try different things. I use a full date time stamp e.g.
httpd.conf-2012-07-16--13-03-00. It takes a bit of time to read the clock and write the full backup file name. I started doing it using the date command to generate the time and date string like so:
cp httpd.conf `date '+%Y-%m-%d--%H-%M-%S'`-httpd.conf
But then I thought why remember the magic percent sequence of the date? So if you edit your
~/.bash_profile and add the following line:
export d="date +%Y-%m-%d--%H-%M-%S"
Now you can create a backup file name really easily:
or if you prefer the date at the end of the file:
cp httpd.conf $d-httpd.conf
cp httpd.conf httpd.conf-$d
Rerunning the above command line creates different file names which are guaranteed not to overwrite each other. You also might want to add a reason for the backup
cp httpd.conf httpd.conf-$d-before-add-bigsoft-virtual-host
No feedback yet
Form is loading...