You are not logged in.
i have been making intermittant snapshots of / using lvm and tar. after the snapshot volume is mounted i enter the following command to do a file backup of the snapshot:
$ tar -pczf /<path of the archive>/<name of the archive> <mounted snapshot>
i would like to start naming my snapshots using the date and time of the system. is there an easy way to issue this command such that <name of archive> contains what is returned by
date +%R\-%D
for instance, i want the archive to be named something like
arroyo1.rootsnapshot.13:25-07/30/09.tgz
TIA
Last edited by poopship21 (2009-08-02 17:16:56)
Offline
arroyo1.rootsnapshot.`date '+%R-%D'`.tgz
if you want to check if it works ... try:
echo arroyo1.rootsnapshot.`date '+%R-%D'`.tgz
[edit]
silly me - of course, you just cannot (or should not) have the '/'-character in a filename!!
I would suggest rather something like this:
date '+%Y%m%d-%H%M'
which also means that you get them neatly ordered when doing a 'ls' ...
[/edit]
Last edited by perbh (2009-07-30 18:00:57)
Offline
arroyo1.rootsnapshot.`date '+%R-%D'`.tgz
if you want to check if it works ... try:
echo arroyo1.rootsnapshot.`date '+%R-%D'`.tgz
[edit]
silly me - of course, you just cannot (or should not) have the '/'-character in a filename!!
I would suggest rather something like this:date '+%Y%m%d-%H%M'
which also means that you get them neatly ordered when doing a 'ls' ...
[/edit]
indeed. this works fine.
Offline
That'll do I use date a little different, e.g:
tar -cvpzf filename-`date +%F`.tar.gz files-to-backup
Which will give me n output:
filename-2009-07-30.tar.gz
Last edited by Gen2ly (2009-07-30 20:38:09)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline