Ik moet het toegeven, sinds ik Ubuntu gebruik ben ik een echte nerd aan het worden! Ik ben nogal een backup-freak, vraag maar aan Defv en Jens.
En omdat ik nogal lui ben heb ik "snel" even een scriptje geschreven die mijn belangrijke files backuped naar mijn zogeliefde fileserver Taro.
Even een korte handleiding: Maak op je fileserver de nodige mappen aan.
Op de machine waarop de te backuppen files staan, doe je onderstaande:
chmod +x /usr/bin/backup
sudo vim /usr/bin/backup
In de file die nu geopend is plaatsje onderstaande code:
# some vars
# path is the dir on the remote pc where the backups will be stored
path="/hier/komen/de/backups/"
#just a timestamp (ex.: 2006.11.06.01.17.23)
time=$(date +%Y.%m.%d.%H.%M.%S)
#rsync the folders you want
rsync -e 'ssh' -azp /te/backuppen/map/ remote_pc:$path"foldername"
#tar the folders for extra backup!
ssh usernam@remote_pc tar -cf $path$time".foldername.tar" $path"foldername/"
#say something! echo "Backup done"
Als je nu "backup" in een console typt (en uitvoert, d'uh) dan zal de map die je ingesteld hebt volledig worden gesynced met de map op de remote pc. En daarachter zal deze worden getared. Bij wijze van voorbeeld kan je mijn scriptje zoals het hier draait hieronder lezen:
# some vars
# path is the dir on the remote pc where the backups will be stored
path="/mnt/disk1/Backups/"
#just a timestamp time=$(date +%Y.%m.%d.%H.%M.%S)
# rsync the folders you want
rsync -e 'ssh' -avzp /mnt/data/crsolutions/ taro:$path"crsolutions"
rsync -e 'ssh' -avzp /mnt/data/PIH/ taro:$path"PIH"
# tar the folders for extra backup!
ssh tys@taro tar -cf $path$time".crsolutions.tar" $path"crsolutions/"
ssh tys@taro tar -cf $path$time".PIH.tar" $path"PIH/"
# say something! echo "Backup done"
PS: werk met een public en private key, dan moet je niet steeds een paswoord ingeven, je kan zo'n key aanmaken met onderstaande code.
ssh-keygen -t rsa
#public key toevoegen op je remote pc
ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote_host