# Backup script



## bsus (Apr 18, 2012)

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 


```
!# /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


----------



## Sebulon (Apr 19, 2012)

@bsus

I have already created a tool for that task, check it out! If you decide to try it, let me know how it went, and if you have any thoughts, suggestions- feel free to share

replicate - Initial and continous ZFS filesystems replication

/Sebulon


----------



## bsus (Apr 19, 2012)

Hi sebulon,

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


```
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


----------



## Sebulon (Apr 19, 2012)

@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


----------



## bsus (Apr 21, 2012)

Thank you, will check it out


----------

