eval "$(df -H "$mountpoint"|awk 'NR>1 {printf "dev=%s\nsize=%s\nfree=%s\nmp=%s",$1,$2,$4,$6;}')"
-message="Backup media inserted into $dev\nTotal space $size\nFree space=$free\n. Would you like to start backup?"
+disk_id=""
+[ -f "$mountpoint/disk_id" ] && disk_id=$(cat "${mountpoint}/disk_id")
+
+message="Backup media ${disk_id} inserted into $dev\nTotal space $size\nFree space=$free\n. Would you like to start backup?"
+
if command -v spacefm; then
iface=spacefm
iface=zenity
fi
+
${iface}_dialog "Backup media inserted" "$message" || exit 0
+
if sudo $BACKUP; then
- ${iface}_monolog "Backup successful" "Backup finished successfully" info
+ ${iface}_monolog "Backup successful" "Backup to disk $disk_id finished successfully" info
else
${iface}_monolog "Backup failed" "Backup finished with errors. See logs" error
exit 1
die "No backup media mounted on $snapshot_root\n" unless -d $snapshot_root;
# Now we have following triples:
# "level,number,nextlevel"
+my ($device, $rootpath) = get_fs($snapshot_root);
+my $disk_id="";
+if ( -f "$rootpath/disk_id" ) {
+ open my $f,"<","$rootpath/disk_id";
+ $disk_id=<$f>;
+ chomp $disk_id;
+}
my $level;
LEVEL:
while (@levels) {
open my $stamp, ">>","$snapshot_root/${nextlevel}-stamp";
close $stamp;
}
+
run_rsnapshot($level);
-notify("Backup completed successfully\n");
+notify("Backup to disk $disk_id completed successfully\n");
# Размонтируем файловую систему, содержащую snapshot_root
-my @lines = `df $snapshot_root`;
-my @line = split(/\s+/,pop @lines);
-my $device = shift @line;
+
$device =~ s/\d$//; # remove partition number
open my $mount,"mount|" or die "Cannot execute mount:$!";
my @to_umount=();
print STDERR "running rsnapshot $level\n";
my $status= system("rsnapshot",$level) >> 8;
if ($status) {
- notify("rsapshot $level finished with code $status\n");
+ notify("rsapshot $level on disk $disk_id finished with code $status\n");
exit $status;
}
}
close $pipe;
}
}
+
+sub get_fs {
+ # returns pair device, mountpoint for fs containing giv en path
+ my $path = $_[0];
+ my @line = split(/\s+/, (`df $path`)[1]);
+ return (shift @line, pop @line);
+}
+
+