Jump to content
Zatarra

Backup Script

Recommended Posts

Posted

Va pun si eu un backup script luat dintr-un server. Poate cineva are nevoie de el ;-)

Daca avetzi intrebari nu ezitati sa le postati


#!/bin/bash
#
# creates backups of essential files
#
DATA="/home /opt /root "
CONFIG="/etc /var/lib /var/named"
DATABACKUP="/mnt/drive2/backup/bofh/data"
CONFIGBACKUP="/mnt/drive2/backup/bofh/config"
DATABASEBACKUP="/mnt/drive2/backup/bofh/database"
LIST="/mnt/drive2/backlist_$$.txt"
#
echo "Starting backup at `date +%Y-%m-%d\ %H:%M:%S`"
echo ""
set $(date)
#
if test "$1" = "Mon" ; then
# weekly a full backup of all data and config. settings:
#
echo "Performing Full Data Backup..."
tar cfz "/mnt/drive2/backup/bofh/data/data_full_$6-$2-$3.tgz" $DATA
echo "Removing incremental data backups..."
rm -f /mnt/drive2/backup/bofh/data/data_diff*
echo "Removing two week old full backup..."
find $DATABACKUP -depth -type f \( -ctime +13 -o -mtime +13 \) -print > $LIST
rm -f `cat $LIST`
#
echo ""
echo "Performing Full Config Backup..."
tar cfz "/mnt/drive2/backup/bofh/config/config_full_$6-$2-$3.tgz" $CONFIG
echo "Removing incremental config backups..."
rm -f /mnt/drive2/backup/bofh/config/config_diff*
echo "Removing two week old full config backup..."
find $CONFIGBACKUP -depth -type f \( -ctime +13 -o -mtime +13 \) -print > $LIST
rm -f `cat $LIST`
else
# incremental backup:
#
echo "Performing Incremental Data Backup..."
find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT "/mnt/drive2/backup/bofh/data/data_diff_$6-$2-$3.tgz" "$LIST"
rm -f "$LIST"
#
echo ""
echo "Performing Incremental config Backup..."
find $CONFIG -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT "/mnt/drive2/backup/bofh/config/config_diff_$6-$2-$3.tgz" "$LIST"
rm -f "$LIST"
fi
#
#
echo ""
echo "Done!"
echo ""
echo "------------------------------------------------------------------------"
echo "Finished: `date +%Y-%m-%d\ %H:%M:%S`"
echo "------------------------------------------------------------------------"
echo ""
exit 0

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...