Shirt Pocket Discussions

Shirt Pocket Discussions (https://www.shirt-pocket.com/forums/index.php)
-   General (https://www.shirt-pocket.com/forums/forumdisplay.php?f=6)
-   -   Touch a file after backup (https://www.shirt-pocket.com/forums/showthread.php?t=5138)

bobm 03-27-2009 07:12 PM

Touch a file after backup
 
Anybody have any suggestions on how to touch a file (the unix command) so that I can look at the backup disk and see when the last backup was done?

I'm now trying to rotate between 2 different backup disks and it would be nice if I could do something like:

> date >last_bkup.txt

put somehow target the backup drive root.

thx

dnanian 03-27-2009 07:45 PM

You can do that with an after-copy shell script, no?

bobm 03-28-2009 12:23 AM

I pondered that.. Of course you reply forced me to read the manual and I found this buried deep down:

43


When SuperDuper executes the script, it passes it six parameters:
1 The name of the source volume (e.g. Macintosh HD)
2 The mount path of the source volume (e.g. /)
3 The name of the destination volume (e.g. Sandbox)
4 The path of the destination (e.g. /Volumes/Sandbox)
5 The name of the script the user selected (e.g. Copy – all files)


6 The name of the image file being processed, if any. This could be either
a source image (if copying from an image to a volume) or a destination
image (if copying from a volume to an image), or a post-copy image
(selected in the After copy options, below)

so I wrote a simple script to touch a file.

Previously I looked at the manual contents and didn't see anything about how to use the script functionality. It turns out that the Advanced features don't get a link on the manual.

Thanks for the suggestion.

dnanian 03-28-2009 07:34 AM

Glad to get you started down the path...

jaked.902 03-28-2009 12:38 PM

Any chance you'd share the script with a not (yet) so unix savvy user?
Thanks
Jake

bobm 03-28-2009 07:10 PM

Last backup time script
 
Here is the script, it needs to be chmod'd executable with the following command:

chmod +x script_name

do this from a terminal session. This script will write a file with the filename being the time the last backup completed.

validate the script works on your system with the following command:

perl -wc script_name

enjoy,
bob

--- start script ---
#!/usr/bin/perl -w
use strict;

#
# this script is called after a backup is made, it assumes the following arguments are passed:
#
# When SuperDuper executes the script, it passes it six parameters:
# 1 The name of the source volume (e.g. Macintosh HD)
# 2 The mount path of the source volume (e.g. /)
# 3 The name of the destination volume (e.g. Sandbox)
# 4 The path of the destination (e.g. /Volumes/Sandbox)
# 5 The name of the script the user selected (e.g. Copy – all files)
# 6 The name of the image file being processed, if any. This could be either
# a source image (if copying from an image to a volume) or a destination
# image (if copying from a volume to an image), or a post-copy image
# (selected in the After copy options, below)
#
# we only really care about the path of the destination.
#

# get where we are putting the file
my $outpath = $ARGV[3];

# get what time it is in a string
my $now = localtime;

# make the name of the file == the path (where we backup'd to
# + the current time.
my $fname = "$outpath/$now";

# open the file, complain and exit if it doesn't seem to work.
open( FP, ">", $fname ) or die "Unable to open $fname, $!";;

# just for the heck of write the timestamp to the file
print FP $now;

# close the file and we're done
close FP;

exit 0; # dunno if SuperDuper looks at the exit codes but this is cleaner.

--- end script ---

jaked.902 04-08-2009 11:25 AM

Thanks
 
Sorry, I forgot to thank you for this - very much appreciated!


All times are GMT -4. The time now is 03:22 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.