Created
April 22, 2016 19:48
-
-
Save leemason/b55f8751af9c4f466f407ec9babe9cb5 to your computer and use it in GitHub Desktop.
Simple tar archive backup script to be placed in the /etc/cron.daily directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH=/usr/sbin:/usr/bin:/sbin:/bin | |
stamp=`date +"%s-%A_%d_%B_%Y@%H_%M"` | |
name="${stamp}_backup.tgz"; | |
#tar filesystem | |
tar cvpzf /backups/file/${name} --exclude=/backups/file --exclude=/lost+found --exclude=/proc/* --exclude=/sys/* --exclude=/mnt/* --exclude=/media/* --exclude=/tmp/* --exclude=/var/run/* --exclude=/var/lock/* --exclude=/var/cache/apt/archives/* --exclude=/home/*/.gvfs --exclude=/run --exclude=/dev / | |
#delete files older than 7 days | |
find /backups/file -type f -mtime +7 -exec rm {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment