1 |
Dale writes: |
2 |
|
3 |
> Me again. I'm thinking about writing a bash script that backs up my |
4 |
> /home directory. I found a guide but before I read all that stuff and |
5 |
> muddy up the waters, is this thing current and will it work fine with |
6 |
> the bash Gentoo uses? Links to a even better guide would be good too. |
7 |
> The guide I found is here: |
8 |
> |
9 |
> http://tldp.org/LDP/abs/html/ |
10 |
|
11 |
I learnt bash that way. And by reading the man page over and over again. |
12 |
And again. Now I have scripts > 100k in size, I had not expected that bash |
13 |
was so powerful. |
14 |
|
15 |
http://www.shelldorado.com/shelltips/ has some nice tips |
16 |
http://sayle.net/book/basics.htm#what_is_a_shell explains what a shell is, |
17 |
maybe that's something to browse first. |
18 |
|
19 |
But for the backup: I recommend rdiff-backup and rsnapshot, I use the |
20 |
former. Basically, it rsyncs a directory, but allows incremental backups, |
21 |
too. After the first backup, the backup directory looks exactly like the |
22 |
original directory, except for a 'rdiff-backup-data' folder containing |
23 |
additional information. When A drive went bad, I just renamed my 1st and |
24 |
2nd drives LVM volume groups and rebooted, now my system ran on the backup |
25 |
drive. |
26 |
The next backups only back up files that have been modified, and save the |
27 |
compressed differences into the rsync-backup-data folder. |
28 |
|
29 |
rsnapshot works similar (but I did not use it yet). The main difference is |
30 |
that rsnapshot creates a whole directory for every backup, containing |
31 |
exactly the files as they were present at the time of backup. Files that |
32 |
stayed the same are not copied, but hard-linked so they take up no extra |
33 |
space. |
34 |
|
35 |
So, I would say, rsnapshot is more practical, at the expense of storage |
36 |
space. If you need a file from an older backup, juts look into the |
37 |
corresponding directory, it is there, just copy it over, no need to use a |
38 |
backup tool to restore stuff. If you want to save space, try rdiff-backup. |
39 |
But if you need a file not from the last backup, but from an earlier one, |
40 |
you need to extract it first with rsnapshot (No big deal, still). |
41 |
|
42 |
My backup script was written in bash of course. It has some targets like |
43 |
'home', 'usr', 'opt' (backup this partition) and extras like 'src' (create |
44 |
.tbz2 files of /usr/src/linux-*), 'etc' (tar /etc) or 'kde' (tar ~/.kde*, |
45 |
I regularly do this before I save the session, because this often does not |
46 |
work). All my data is on LVM volumes, so when a partition is to be backed |
47 |
up, a LVM snapshot is created and used for the backup. So I can continue |
48 |
working in my home directory and change data during the backup. |
49 |
The script is here: http://wonkology.org/~wonko/tmp/backup |
50 |
|
51 |
Wonko |