Created
October 16, 2016 08:34
-
-
Save bartekkois/a73dc2ad5c5b717e5af38861134f339a to your computer and use it in GitHub Desktop.
Script for periodical backup of /etc 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/sh | |
# ------------ BACKUP 1.0.0 "rc.backup" ------------- | |
# All rights reserved for B@roo 2000-2016 | |
# ----------------------------------------------------- | |
#set -x | |
# ------------------- Configuration ------------------- | |
DIR=/var/log/backup | |
# ------------------- Create backup ------------------- | |
FILE=backup-`date '+%Y-%m-%d'`.tar.gz | |
if [ -e $DIR'/'$FILE ] ; then | |
echo "Backup already exists !!!" | |
exit 0 | |
fi | |
tar cvf - /etc | gzip -c > $DIR'/'$FILE | |
echo "Backup created." | |
# --------------- Remove old archives ----------------- | |
find /var/log/backup -ctime +7 -type f -name "backup-*" -exec rm -rf {} \; | |
echo "Backup rotated." |
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
# Create backup | |
00 1 * * * root /root/system_scripts/backup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment