You are not logged in.

#1 2008-12-18 22:30:34

jelly
Administrator
From: /dev/null
Registered: 2008-06-10
Posts: 714

Custom Backup Script

Well it's almost christmass for you all, i already had sinterklaas in the Netherlands. Wich bought me a nice 1 TB networkattached storage i can conect to this device with samba or ftp. I know want to make a custom backup script ( i don't know i am in the right forum but i am a newbie at this wink ). I know backups are quite important so i figured out a backup plan every week i want to make a full backup ( with tar) and every 2 days a incremental backup.

I plan to use samba and i have mounted it on /mnt/nas_backup. I want this script to mount this share and make a tar in my home directory and then copy it to the directory of the share

 DAY=`date "+%F_%H:%M"`
share="/mnt/nas_backup/BackupP6"
backupmap="/home/jelle"
mount -t cifs //192.168.2.101/myshare /mnt/nas_backup -o username=admin,password=xxxxx

cd /home/jelle/backup
tar cvpzf backupfullP6_$DAY.tgz /home/jelle --exclude=/home/jelle/.mozilla/firefox/*.default/Cache --exclude=/home/jelle/backup --exclude=/home/jelle/.Trash --exclude=/home/jelle/.local/share/Trash/files --exclude=/home/jelle/Muziek --exclude=/home/jelle/Movies
tar cvpzf backupfullP6_$DAY-etc.tgz /etc
tar cvpzf backupfullP6_$DAY-var.trz /var

mv /home/jelle/backupfullP6_Date.tgz share
umount /mnt/nas_backup

Is this a good script, i want to use cron to shedule it to run it every week.

But now i need incremental backups should i use rsync for this?
i have seen this code on the arch wiki
#!/bin/bash
rsync -ar --delete /folder_to_backup/ /location_to_backup/ &> /dev/null

I also own a laptop wich i also want to backup, but it isn't always on my home location, so can i write a script that checks if i am in my network and then makes a backup ?

Offline

#2 2008-12-18 23:11:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Custom Backup Script

Looks pretty good... A few points though...
1. Why create an intermidiate file? Why not just write directly to /mnt/nas_backup?
2. rsync won't recognise your tar backup, so you'll actually be creating 2 backups. One tar'ed and one rsync.

Personally, I use just rsync for my data backups. After the initial backup, it keeps it nice and fast. Especially on my laptop over the wireless network. Here's the command I use:

/bin/date > ~/last_backup.txt
/usr/bin/rsync -av --delete --exclude=.Trash* --exclude=.gvfs --exclude=.smb --exclude=.local/share/Trash --exclude=.mozilla/firefox/*/Cache ~/ rsync://server/BackupData/fukawi2-Desktop/

Makes it easy to restore a single file too. Just a simple copy/paste from the server. Don't have to worry about tar'ing.

I do still use tar though, but only for configuration backups. The script is here:
http://pastebin.com/f23fd09ac

Offline

#3 2008-12-19 01:03:07

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Custom Backup Script

Rdiff-backup in community will take care of a lot of the extra work for you doing incremental backups.

Scott

Offline

#4 2008-12-19 08:44:05

jelly
Administrator
From: /dev/null
Registered: 2008-06-10
Posts: 714

Re: Custom Backup Script

fukawi2 wrote:

Looks pretty good... A few points though...
1. Why create an intermidiate file? Why not just write directly to /mnt/nas_backup?
2. rsync won't recognise your tar backup, so you'll actually be creating 2 backups. One tar'ed and one rsync.

Personally, I use just rsync for my data backups. After the initial backup, it keeps it nice and fast. Especially on my laptop over the wireless network. Here's the command I use:

/bin/date > ~/last_backup.txt
/usr/bin/rsync -av --delete --exclude=.Trash* --exclude=.gvfs --exclude=.smb --exclude=.local/share/Trash --exclude=.mozilla/firefox/*/Cache ~/ rsync://server/BackupData/fukawi2-Desktop/

Makes it easy to restore a single file too. Just a simple copy/paste from the server. Don't have to worry about tar'ing.

I do still use tar though, but only for configuration backups. The script is here:
http://pastebin.com/f23fd09ac

Well i want to make full backups and incremental backups, incremental with rsync and full with tar. But i still want to fix this script to automaticlly backup my laptop when it is in my home network maybe i can compare the gateway.

Offline

#5 2008-12-19 09:28:15

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: Custom Backup Script

Seems like the easiest way to check for your home network is to just try to mount the NAS share. You'll likely not find the 192.168.2.101 IP working on an outside network.


Also, what about some kind of revision control system for doing the backups. That way you would have versions of files that you could go back and recover if necessary. I've never done this but I have always wanted to try.

Offline

#6 2008-12-19 22:34:36

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Custom Backup Script

The other option to do incrementals would be to psuedo-snapshots using rsync. I've done this before, and it's awesome:
http://www.mikerubel.org/computers/rsync_snapshots/

Offline

#7 2008-12-20 15:12:02

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Custom Backup Script

out of curiosity, which disk did you get?


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#8 2008-12-20 16:10:22

jelly
Administrator
From: /dev/null
Registered: 2008-06-10
Posts: 714

Re: Custom Backup Script

Lacie NetworkSpace 1 TB it works very well with Linux! , you can use a samba share or use fpt.  It's also has a daap-server running, rhythmbox detected that share perfect. Also it has a usb key backup function. I like it very much now i can save all my series i download tongue

Last edited by jelly (2008-12-20 16:36:31)

Offline

Board footer

Powered by FluxBB