vzdump with datestamps [message #34522] |
Thu, 15 January 2009 05:24  |
vader897
Messages: 2 Registered: January 2009
|
Junior Member |
|
|
I am trying to edit vzdump so that it will append the date and maybe time to the filename of the outputted tar file.
for example vzdump-VEID-%Y-%m-%d-%H-%M-%s.tar.gz
It seems fairly straight foward
On a side note, I think a nifty upgrade for vzdump would be for it to allow users to append a label. For example, vzdump 101 -L my_special_backup would spit out a file called vzdump-101-my_special_backup.tar.gz
Dont get sidetracked by my feature request, the real question is how can I edit the vzdump code jus to get a datestamp for now. The line that needs to be changed is 1287.
my $basename = "vzdump-${vpsid}";
basically, i have never coded in perl before so I have just been guessing at code to no avail. Can anyone lend me a hand?
Any ideas?
|
|
|
Re: vzdump with datestamps [message #34612 is a reply to message #34522] |
Tue, 20 January 2009 23:59  |
vader897
Messages: 2 Registered: January 2009
|
Junior Member |
|
|
Figured it out myself.
I changed
my $basename = "vzdump-${vpsid}";
to this
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst)=localtime(time);
$year += 1900;
$mon += 1;
my $basename = "vzdump-${vpsid}-$year-$mon-$mday-$hour-$min-$sec";
Maybe thats helpful to someone else. The reason why I wanted to do this was so that vzdump wouldnt overwrite files, I thought appending the date to the filenames would be more useful than just a number.
What I will do next is write a script to set as a cronjob which will do a few things.
1. dump all VE's every night
2. delete all VE's older than 2 weeks except for ones dumped on sunday.
3. delete all VE's older than 1 month except for the ones dumped on the first sunday of the month
you get the idea...
|
|
|