Backup script

Hi,

I need to write a backup script which:
1. Creates daily snapshots
2. Deletes old snapshots
3. Sends snapshots to another volume

Because its long ago I used some sh I need some syntactic help :(

Code:
!# /bin/sh

PATH="storage/home/user"
DATE=`/bin/date "+%d.%m.%Y"`

`/sbin/zfs snapshot $PATH@$DATE`

INTERVAL="90d"
EXPIRED=`/bin/date -v-${INTERVAL}`

SNAPSHOTS=`zfs list -t snapshot | grep ${PATH}`

# compare the snapshot names in SNAPSHOTS with the EXPIRED name and delete them

Could somebody help me with the last task.
How I compare them properly?

Best Regards,
bsus
 
Hi sebulon,

Thank you for this alternative. This saves a lot of time. Is there an available manual for the script?

Code:
 echo ""
 echo "Usage:        `basename $0` [Options] [Flags] [Job]"
 echo ""
 echo "Options: -c|-h"
 echo "-c:           Clean."
 echo "              removes replicated filesystems and snapshot(s)."
 echo "-h:           Usage."
 echo ""
 echo "Flags: auto"
 echo "auto:         Clean auto."
 echo "              removes all scheduled snapshot(s)."
 echo ""
 echo "Examples:     `basename $0` | `basename $0` jobname"
 echo "              `basename $0` -c | `basename $0` -c jobname | `basename $0` -c auto"
 echo ""

I am a little careful about scripts accessing data :)
 
@bsus

Yes, I wrote a man-page, and a little more describing README is inside the install-package. You can RTFM all you want (always wanted to say that:))

/Sebulon
 
Back
Top