You've loaded an old revision of the document! If you save it, you will create a new version with this data. Media Files====== Backup Script Linux ====== ===== Data collector ===== <code bash> #!/bin/sh # Remote Server Backup Script v1.6 by PsyCore # vars BCF=my.backup.tar BCF2=sql.backup.tgz NFSDir="/mnt/storage/" SQLUser=sqladmin SQLPass=moresecretthansecret SUBJECT="My Backup Status" EMAIL="notification@my-email.tld" EMSG="/tmp/emsg.txt" ATTACH="/tmp/attach.txt" DATE=$(date +%u) EnableFileBackup=1 EnableSQLBackup=1 EnableCronBackup=1 EnableCloudBackup=1 run_date=`date +'%d.%m.%Y %H:%M:%S'` echo "Backup Status: " >$EMSG echo "rsync log" >$ATTACH if [ "$EnableSQLBackup" = "1" ] then echo "SQL Backup started " `date +'%d.%m.%Y %H:%M:%S'` >$EMSG #date +'%d.%m.%Y %H:%M:%S' mysqldump -u $SQLUser -p$SQLPass --all-databases > root_full.sql mysqldump -u $SQLUser -p$SQLPass --databases db1 > db1.sql mysqldump -u $SQLUser -p$SQLPass --databases dbx > dbx.sql tar cvfz sql.backup-$DATE.tgz *.sql cp -u sql.backup-$DATE.tgz /root/backup-database cp -u sql.backup-$DATE.tgz $NFSDir fi # backup cron tasks if [ "$EnableCronBackup" = "1" ] then echo "Cron Backup started " `date +'%d.%m.%Y %H:%M:%S'` >>$EMSG #date +'%d.%m.%Y %H:%M:%S' crontab -l > crontab.txt tar cvfz crontab.tgz *.txt fi if [ "$EnableFileBackup" = "1" ] then echo "File Backup started " `date +'%d.%m.%Y %H:%M:%S'` >>$EMSG #date +'%d.%m.%Y %H:%M:%S' tar cvfz webs.tgz /var/www/dir1 /var/www/dir2 /var/www/dirx fi if [ "$EnableCloudBackup" = "1" ] then echo "Cloud Backup started " `date +'%d.%m.%Y %H:%M:%S'` >>$EMSG #date +'%d.%m.%Y %H:%M:%S' rsync -a -v --exclude-from 'backup-exclude.txt' --stats --delete /usr/share/cloud-dir $NFSDir >> $ATTACH fi # archive all tar cvf $BCF *.tgz # NFS Storage cp $BCF $NFSDir # cleanup rm -f *.sql rm -f *.tgz rm -f *.tar #rm -f *.txt # grep "bytes sent" backup.log>>$EMSG # grep "221 Goodbye" backup.log>>$EMSG echo "Backup beendet: " `date +'%d.%m.%Y %H:%M:%S'` >> $EMSG echo " ">>$EMSG echo "remote storage: ">>$EMSG echo "==========================">>$EMSG ls -ashl $NFSDir>>$EMSG echo "database archive: ">>$EMSG echo "==========================">>$EMSG ls -ashl /root/backup-database/>>$EMSG mail -A $ATTACH -s "$SUBJECT" "$EMAIL" < $EMSG rm $EMSG #date +'%d.%m.%Y %H:%M:%S' # EOF </code>Please solve the following equation to prove you're human. 157 +4 = Please keep this field empty: SavePreviewCancel Edit summary Note: By editing this page you agree to license your content under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International