You are not logged in.

#1 2009-07-30 17:29:43

poopship21
Member
Registered: 2009-05-13
Posts: 177

backup lvm snapshots using $date in filenames [SOLVED]

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

#2 2009-07-30 17:54:53

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: backup lvm snapshots using $date in filenames [SOLVED]

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

#3 2009-07-30 18:20:00

poopship21
Member
Registered: 2009-05-13
Posts: 177

Re: backup lvm snapshots using $date in filenames [SOLVED]

perbh wrote:
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

#4 2009-07-30 20:34:21

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: backup lvm snapshots using $date in filenames [SOLVED]

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

Board footer

Powered by FluxBB