Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Begin:
- restic init --repo /var/backups
- # passwd
- # Backup:
- restic backup --repo /var/backups /home/maria
- # View:
- restic snapshots
- restic diff a8aa6cef 4228f83e
- # Mount snapshot:
- restic mount /mnt
- # Restore
- restic restore latest --target ~/restored-data
- # Script for auto backup and cleanup:
- LOGFILE=/var/log/restic.log
- LOCKFILE=/var/backups.remote/restic.lock
- RESTIC_REPOSITORY=/var/backups
- RESTIC_PASSWORD=*****
- if [ ! -d ${RESTIC_REPOSITORY} ]
- then
- echo "$(date) Repository not found, trying to mount"
- mount /var/backups.remote 2>&1
- fi >>${LOGFILE}
- if [ ! -d ${RESTIC_REPOSITORY} ]
- then
- echo "$(date) Repository still not mounted, exiting"
- exit 1
- fi >>${LOGFILE}
- Delay=$(( ${RANDOM} / 1000 ))
- echo "$(date) First, sleeping for ${Delay} sec..." >>${LOGFILE}; sleep ${Delay}
- while [ -f ${LOCKFILE} ]
- do
- Delay=$(( ${RANDOM} / 1000 ))
- echo "$(date) Lock file found, sleeping for ${Delay} sec..." >>${LOGFILE}; sleep ${Delay}
- done
- echo "$(date) Now processing backup..." >>${LOGFILE}
- touch ${LOCKFILE}
- (restic backup /usr/share/nginx/html) >>${LOGFILE} 2>&1 && date >/tmp/restic-success
- (restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 3
- restic prune) >>${LOGFILE}
- echo "$(date) Backup is done" >>${LOGFILE}
- rm -f ${LOCKFILE}
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement