Hi everyone,
I'm trying to set up cron to store daily snapshots of my entire filesystem, but it's not working out how I'd expect.
I have the partition /usr, and I'd like to store a snapshot of it at /usr/snapshot/snap. I can do this manually like so:
So, I made a script to do this for me for each partition. It looks like this (repeated for each partition, but let's assume I'm just worried about snapshotting /usr):
When I run this script, it moves the snapshot /usr/snapshot/snap to /usr/snapshot/snap_old, and then creates a new /usr/snapshot/snap. It works fine when I run it manually, and usually takes about 1~2 minutes (it's a 25Gb filesystem).
Now, for whatever reason, when I put this into a cron script, it doesn't work how I'd expect it to. It moves the current snapshot to snap_old, but the mount command doesn't seem to do its job. Here's the /etc/crontab entry (where /root/backup.sh is the above script) :
----OS Information:----
I'd be grateful if anyone could help me out. I'd be glad to provide more information, but I'm not too sure which log files (if any) would lead to any clues here.
I'm trying to set up cron to store daily snapshots of my entire filesystem, but it's not working out how I'd expect.
I have the partition /usr, and I'd like to store a snapshot of it at /usr/snapshot/snap. I can do this manually like so:
Code:
mount -u -o snapshot /usr/snapshot/snap /usr
So, I made a script to do this for me for each partition. It looks like this (repeated for each partition, but let's assume I'm just worried about snapshotting /usr):
Code:
#!/bin/sh
if [ -f /usr/snapshot/snap ]; then
rm -f /usr/snapshot/snap_old
mv /usr/snapshot/snap /usr/snapshot/snap_old
fi
mount -u -o snapshot /usr/snapshot/snap /usr
When I run this script, it moves the snapshot /usr/snapshot/snap to /usr/snapshot/snap_old, and then creates a new /usr/snapshot/snap. It works fine when I run it manually, and usually takes about 1~2 minutes (it's a 25Gb filesystem).
Now, for whatever reason, when I put this into a cron script, it doesn't work how I'd expect it to. It moves the current snapshot to snap_old, but the mount command doesn't seem to do its job. Here's the /etc/crontab entry (where /root/backup.sh is the above script) :
Code:
# Perform daily snapshot at 3:00 AM
0 3 * * * root /root/backup.sh
----OS Information:----
Code:
$ uname -a
FreeBSD dell.petio.org 7.0-RELEASE FreeBSD 7.0-RELEASE #2: Tue Dec 23 01:38:59 EST 2008 [email]root@dell.petio.org[/email]:/usr/obj/usr/src
/sys/DELL i386
I'd be grateful if anyone could help me out. I'd be glad to provide more information, but I'm not too sure which log files (if any) would lead to any clues here.