Bash Scripting
On this page I will be displaying some of the bash scripts that I have created.
Server Backup with rsync
Basically what this script will SSH into another server, restart MySQL, dump some databases, and copy over those files plus some others.
#!/bin/bash ssh "root@192.168.2.109" "/etc/init.d/mysql restart" ssh "root@192.168.2.109" "mysqldump -u root --password=S0mePassw0rd testdb > testdb.sql" scp root@192.168.2.109:testdb.sql /media/usbdrive/ scp -r root@192.168.2.109:/var/www/ /media/usbdrive/www/
As you can see I copied the files to the machine that will run the script and put them on the USB drive that is mounted.
Full System Backup
This script will show you how to do a complete system backup.
#!/bin/bash tar cvzpf /mnt/extdrive/backupfilename.tgz --same-owner --exclude=/mnt/extdrive/backupfilename.tar.gz --exclude=/proc/* --exclude=/media/* --exclude=/dev/* --exclude=/mnt/* --exclude=/sys/* --exclude=/tmp/* /