BASH
34
[debian] Mount network drives (fstab), cron, delete-cycle By micha on 20th August 2018 04:47:36 PM
- /etc/fstab
- //192.168.2.240/aliaz-Server2/aliaz\040GmbH/Webentwicklung/_SERVER_web-server_auto-backup /mnt/web_ext_backups cifs username=backup_user,password={PASSWORD},iocharset=utf8,sec=ntlm 0 0
- //Read fstab and remount
- mount -a
- //Mount a network drive temporary
- mount -t cifs -o username=backup_user,password=hv7t64g9 //192.168.2.69/aliaz-Server2/aliaz\ GmbH/Webentwicklung/_SERVER_web-server_auto-backup
- //MySQL Backup -All DBs
- Datum=`/bin/date '+%Y-%m-%d---%H-%M-%S'` && mysqldump -uroot -phv7t64g9 --all-databases > /mnt/data/Webserver/SQL/sql_$Datum.sql
- //Delete SQL Files older than 10 days
- /usr/bin/find /mnt/data/Webserver/SQL -type f -mtime +10 | xargs rm -rf
- //Find Files newer than 1 day
- find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime -1
- //Copy the generated local backup file (newer than 1 day) from debian linux maschine to the mounted network drive
- find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime -1 -exec cp -t /mnt/web_ext_backups/ {} \;
- find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime -1 | xargs cp -t /mnt/web_ext_backups/
- //Do the same for our SQL backup file
- find /mnt/data/Webserver/SQL/* -maxdepth 0 -type f -mtime -1 -exec cp -t /mnt/web_ext_backups/ {} \;
- find /mnt/data/Webserver/SQL/* -maxdepth 0 -type f -mtime -1 | xargs cp -t /mnt/web_ext_backups/
- //Remove (delete) Backup files older than 2 month from backup_dir
- find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime +60 | xargs rm -rf
- //Remove older files than 1 day on external mounted drive (NAS)
- find /mnt/web_ext_backups/* -maxdepth 0 -type f -mtime +1 | xargs rm -rf
- //Das Backup des kompletten htdocs Verzeichnisses wird über das Webmin Modul "Filesystem Backup" erstellt.
- Backup Format: Unix TAR
- Backup Directory: /var/www/html
- Backup to: /mnt/data/Webserver/html_%A.tar.gz
- /var/spool/cron/crontabs
- @daily Datum=`/bin/date '+\%Y-\%m-\%d---\%H-\%M-\%S'` && mysqldump -uroot -phv7t64g9 --all-databases > /mnt/data/Webserver/SQL/sql_$Datum.sql #MySQL Backup -All DBs
- @weekly /usr/bin/find /mnt/data/Webserver/SQL -type f -mtime +10 | xargs rm -rf #Delete SQL Files older than 10 days
- @daily find /mnt/data/Webserver/SQL/* -maxdepth 0 -type f -mtime -1 | xargs cp -t /mnt/web_ext_backups/ #Copy the generated local backup file (SQL) (newer than 1 day) from debian linux maschine to the mounted network drive
- @daily find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime -1 | xargs cp -t /mnt/web_ext_backups/ #Copy the generated local backup file (tar.gz) (newer than 1 day) from debian linux maschine to the mounted network drive
- @daily find /mnt/web_ext_backups/* -maxdepth 0 -type f -mtime +1 | xargs rm -rf #Delete older files than 1 day on external mounted drive (NAS)
- @weekly find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime +60 | xargs rm -rf #Delete Backup-Cycle files older than 2 month
- ---
- @daily Datum=`/bin/date '+\%Y-\%m-\%d---\%H-\%M-\%S'` && mysqldump -uroot -phv7t64g9 --all-databases > /mnt/data/Webserver/SQL/sql_$Datum.sql | echo "Job completed by debian-aliaz: $Datum" | mail -s "[debian-aliaz] Cronjob - MySQL dump completed" admin@aliaz.de #MySQL Backup -All DBs
- @weekly /usr/bin/find /mnt/data/Webserver/SQL -type f -mtime +10 | xargs rm -rf #Delete SQL Files older than 10 days
- 0 1 * * * find /mnt/data/Webserver/SQL/* -maxdepth 0 -type f -mtime -1 | xargs cp -t /var/www/sql/ | echo "Job completed by debian-aliaz: Copy the generated local backup file (SQL) (newer than 1 day) from debian linux maschine backup dir to web directory for rsync service" | mail -s "[debian-aliaz] Cronjob - SQL copied to web directory for rsync service" admin@aliaz.de #Copy the generated local backup file (SQL) (newer than 1 day) from debian linux maschine backup directory to web directory for rsync service
- @weekly find /mnt/data/Webserver/* -maxdepth 0 -type f -mtime +60 | xargs rm -rf #Delete Backup-Cycle files older than 2 month
- 15 1 * * * find /var/www/sql -type f -mtime +1 | xargs rm -rf | echo "Job completed by debian-aliaz:" | mail -s "[debian-aliaz] Cronjob - MySQL cleanup for rsync" admin@aliaz.de
- 30 1 * * * rsync -ahv --delete --no-o --no-g --no-p --log-file=/var/www/html/rsync.log --password-file=/root/rsync_pass /var/www/ backup_user@192.168.2.240::Aliaz-Webdev/debian-aliaz-linux-01/ #Sync webserver (/var/www) to NAS01-HA #Sync webserver (/var/www) to NAS01-HA #Sync webserver (/var/www) to NAS01-HA
Recent Pastes