"Fossies" - the Fresh Open Source Software Archive 
Member "fsbackup-1.2pl2/fsbackup_eng_guide.txt" (10 Oct 2005, 14039 Bytes) of package /linux/privat/old/fsbackup-1.2pl2.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 Step-by-step guide by kubrack <ak at tim.ua>
2
3 Install & Config
4 -----------------------------------------------------
5 1) Log in system as root
6
7 2) wget http://www.opennet.ru/dev/fsbackup/src/fsbackup-1.2pl1.tar.gz
8 If you have not wget you can download this file in any browser.
9
10 3) tar -zvxf fsbackup-1.2pl1.tar.gz
11
12 4) cd fsbackup-1.2pl1/
13
14 5) ./install.pl
15 If you want to install fsbackup in other directory
16 (/usr/local/fsbackup/ by default), you may owerride it by --prefix
17 directive, for example: ./install.pl --prefix /usr/fsbackup/
18
19 You may answer by default on all script questions (simply Enter)
20 You will see 'Installation complete' message after install done.
21
22 6) Now, you have fsbackup installed fully in /usr/local/fsbackup (or
23 other --prefix ) directory. It consist scripts, config example and docs
24 in some directories.
25
26 Main script is create_backup.sh. It must be run periodicy via cron, or
27 manualy, if necessary. In this one, you may determine one or more
28 config files. Every config file will describe one set of backups.
29
30 First, save original files:
31
32 cd /usr/local/fsbackup/
33 cp -v create_backup.sh create_backup.sh.orig
34 cp -v cfg_example my_backup1.cfg
35
36 7) Edit them:
37 joe create_backup.sh
38 (I like a joe, but you may be have other favorites, as vi or ed :)
39 In create_backup.sh, we must change only "config_files" perameter (row 33). Set it to
40
41 config_files="my_backup1.cfg"
42
43 end examine others:
44
45 backup_path="/usr/local/fsbackup" - leave untouched, if you don't use --prefix option for install.pl
46 backup_mysql=0
47 backup_pgsql=0
48 backup_sqlite=0
49 backup_sys=0
50
51 - if we dont want to backup databases and sysconfigs. Otherwise, we must
52 edit scripts/* too. Write me pls if you want it.
53
54 Save it end exit from editor.
55
56 8) joe my_backup1.cfg
57
58 row 13: $cfg_backup_name - simply tag of backup. Hostname by
59 default. May contain [a-z,A-Z,0-9,_] only.
60
61 row 22: $cfg_cache_dir - backup cache directory. If possible, leave
62 "/usr/local/fsbackup/cache"
63
64 rows 36-40: $prog_* - may be checked, but usually true for RH.
65
66 NOTES:
67
68 * if you dont want enscryption, set $prog_pgp = "". Be sure: it about
69 enscryption of entry archive, NOT simply protect it for transfer to
70 network backup server (SSH will describe below). It may eat many
71 resources for big backups.
72
73 * if you want enscryption and set $prog_pgp = "/usr/bin/gpg", set
74 $prog_gzip = "", because gpg will already compress it.
75
76 row 56: $cfg_checksum - used for incremental backup, "timesize" recomended.
77
78 row 75: $cfg_backup_style - "backup" for incremental backup
79
80 row 85: $cfg_increment_level - as described, after how many
81 incremental copy make full refresh of backup. If 0, don't make full refresh.
82
83 row 100: $cfg_save_old_backup - save or not OLD backup.
84
85 row 114: $cfg_type - for local part of your project, must be
86 "local". Use dedicated HD for backup destination is recommended.
87
88 For you demands, must be created two configs (and placed into create_backup.sh):
89
90 * first, for backup all demanded dirs or files, with $cfg_type="local"
91
92 * other, for move first backup to another server, with $cfg_type=
93 "remote_ssh" or "remote_ftp", in which result of first backup
94 ($cfg_local_path) described as backuped dir.
95
96 About methods: ssh is more secure, but ftp is more quickly. If both
97 servers are placed in one ethernet segment, with trusted hosts only, use
98 ftp. Otherwise, ssh.
99
100 For ssh method certificate must be generated on backup destination
101 server and placed into user's home on another server.
102
103 row 122-124: $cfg_remote* - settings for remote cfg_types.
104
105 row 135: $cfg_remote_ftp_mode - 1 if you have problem with firewalls between servers.
106
107 row 142: $cfg_remote_password - for ftp login to remote server.
108
109 row 152: $cfg_local_path - if $cfg_type=local, backups will be
110 placed here. Not the some with cache! Must be already created. Dont
111 forget exclude it from directories for backup below.
112
113 row 162: $cfg_time_limit - as described, 0 for all.
114
115 row 172: $cfg_size_limit - as described, in KB
116
117 row 186: $cfg_maximum_archive_size - BEFORE compression!
118
119 row 195: $cfg_root_path - change it if you want describe all not from root dir.
120
121 row 206: $cfg_pgp_userid - as described, for enscryption.
122
123 row 222: $cfg_verbose - verbose level
124
125 row 241: $cfg_stopdir_prune - leave untouched
126
127 So, for local backup I have change next setting:
128
129 $prog_pgp = "";
130
131 Below, you have a list of backuped files & directories. For Linux,
132 comment out strings 326,327 (BSD pkgs & kernel), and edit other for your
133 directories.
134
135 My list:
136
137 __DATA__
138 /usr/local/fsbackup
139 !/usr/local/fsbackup/cache
140 !/usr/local/fsbackup/archive
141 f!\.core$
142 f!^core$
143 f!\.o$
144 f!\.log$
145
146 # Linux
147 /usr/src/linux/.config
148
149 # Users
150 /home
151 /root
152 !/home/ftp
153 =!\.netscape/cache/
154 =!\.mozilla/.*/Cache/
155 =!\.mozilla/.*/NewCache/
156 =!\.mozilla/.*/News/
157 f!.*\.avi$
158 f!.*\.mpeg$
159 f!.*\.mpg$
160 f!.*\.mp3$
161
162 # System configuration
163 /etc
164 /var/cron/tabs
165 /var/spool/cron
166 /usr/local/etc
167
168 NOTE: I have dedicated HDD mount to /usr/local/fsbackup/archive
169
170 8) Creating the local backup dir & protect it:
171
172 mkdir -p /usr/local/fsbackup/archive
173 chmod 700 /usr/local/fsbackup/archive
174
175 9) Planning of backup:
176
177 joe /etc/crontab
178
179 add string:
180
181 1 1 * * 1 root /usr/local/fsbackup/create_backup.sh
182
183 for weekly backup, or
184
185 1 1 * * * root /usr/local/fsbackup/create_backup.sh
186
187 for daily backup. You can run it as "nice -n 5 /usr/local/fsbackup/create_backup.sh"
188 if you want decrease CPU load by backup for other apps.
189
190 10) Testing fsbackup:
191
192 # /usr/local/fsbackup/create_backup.sh
193 Creating local backup: router_ap01
194 Current increment number: 0
195 Adding /usr/local/fsbackup....
196 done
197 Adding /usr/src/linux/.config....
198 done
199 Adding /home....
200 done
201 Adding /root....
202 done
203 Adding /etc....
204 done
205 Adding /var/cron/tabs....
206 done
207 Adding /var/spool/cron....
208 done
209 Adding /usr/local/etc....
210 done
211 Storing local backup...
212 ***** Backup successful complete.
213
214 11) And verify:
215
216 # ls -l /usr/local/fsbackup/archive
217 total 11088
218 -rw-r--r-- 1 root root 11091270 Sep 10 02:23 router_ap01-2005.09.10.02.23.00-0.tar.gz
219 -rw-r--r-- 1 root root 0 Sep 10 02:23 router_ap01-2005.09.10.02.23.00.del
220 -rw-r--r-- 1 root root 28874 Sep 10 02:23 router_ap01-2005.09.10.02.23.00.dir
221 -rw-r--r-- 1 root root 172032 Sep 10 02:23 router_ap01-2005.09.10.02.23.00.hash
222 -rw-r--r-- 1 root root 36191 Sep 10 02:23 router_ap01-2005.09.10.02.23.00.list
223 -rw-r--r-- 1 root root 41787 Sep 10 02:23 router_ap01-2005.09.10.02.23.00.lsize
224
225
226 --- Write me your questions pls. Answers & about restore from backup in
227 next mail.
228
229
230 Restoring
231 -----------------------------------------------------
232
233 For restoring data from the backup, we can use script
234 /usr/local/fsbackup/scripts/fsrestore.sh
235
236 May be you want to save this file separately, simply in backup dir, for
237 more quickly restoring:
238
239 cp -v /usr/local/fsbackup/scripts/fsrestore.sh /usr/local/fsbackup/archive/
240
241 1) Make some changes:
242
243 joe /usr/local/fsbackup/scripts/fsrestore.sh
244 there are 3 options here:
245
246 * backup_name
247 tag of data for extract (if you have more than 1 config for fsbackup,
248 you can restore it separately)
249
250 * backup_path
251 in our fsbackup config we have "/usr/local/fsbackup/archive", but may
252 be after crash you will want mount dedicated HD to other point..
253
254 * restore_path
255 this dir will be "root point" for the extracted data.
256
257 2) do restoring process:
258 /usr/local/fsbackup/scripts/fsrestore.sh
259
260 Removing deleted files for router_ap01-2005.09.10.02.23.00-0.tar.gz...
261 Restoring router_ap01-2005.09.10.02.23.00-0.tar.gz...
262 Fixing directory permissions for router_ap01-2005.09.10.02.23.00-0.tar.gz...
263 mkdir: cannot create directory `./usr/local/fsbackup': File exists
264 mkdir: cannot create directory `./usr/local/fsbackup/scripts': File exists
265 mkdir: cannot create directory `./root': File exists
266 ...
267
268 dont worry about "mkdir: cannot create directory" warnings: it simple
269 try to create already created dirs in second pass of restoring.
270
271 fsrestore.sh will create all your data from base & all increments of
272 archive. Check it!
273
274
275 FAQ
276 -----------------------------------------------------
277
278 > Q: Local Backup done! Worked like a charm .. your instructions
279 > were great. So my plan is to do a local backup every day (incremental
280 > everyday and a full backup every 7 days).
281
282 A: For auto-run fsbackup every day we need put
283 /usr/local/fsbackup/create_backup.sh into Unix sheduler (/etc/crontab):
284
285 cat >> /etc/crontab <<_END_
286 1 1 * * * root /usr/local/fsbackup/create_backup.sh
287 _END_
288
289 now your backup will be run every day at 1:01 AM.
290 Behaviour of incremental-full backup determining into row 85 of /usr/local/fsbackup/my_backup1.cfg:
291
292 $cfg_increment_level = 7;
293 7 = 1 full backup after every 6 incremental backups
294
295 > Q: However, to copy backups to remote system, I am thinking of using "rsync
296 > over ssh" rather than using another config file with fs_backup. What do you
297 > think about that ? Will that work ?
298
299 A: Yes, but fsbackup can do it itself via ssh. Configuring this below:
300
301 Lets HOST_FROM is machine which from we need secure coping files, and
302 HOST_TO is machine which to we will to copy (server).
303
304 (1) Make ssh serificate on HOST_FROM:
305
306 Login as root (because this user must have permissions for access to
307 backuped files in this host, may be some other, if no need to backup
308 system dirs);
309
310 root@HOST_FROM# ssh-keygen -t rsa ;
311 answer questions ;
312 root@HOST_FROM# ssh-keygen -t dsa ;
313 answer questions ;
314 root@HOST_FROM# cat ~/.ssh/id_rsa.pub ;
315 root@HOST_FROM# cat ~/.ssh/id_dsa.pub ;
316 copy anywhere result of two last command (2 rows) ;
317
318 (2) On host HOST_TO:
319 (2.1)Make sure to exist & uncomment next lines in your sshd config (usualy /etc/ssh/sshd_config) :
320
321 RSAAuthentication yes
322 PubkeyAuthentication yes
323 AuthorizedKeysFile .ssh/authorized_keys
324
325 If no, add its and restart sshd (/etc/init.d/sshd restart)
326
327 (2.2) Create .ssh directory in home of user, who will be owner to
328 fsbackup repository. Usually he is ordinate user, not root, for security
329 reason.
330
331 Make ~/.ssh/authorized_keys file there, and grant permissions:
332
333 root@HOST_TO# su - someuser
334 someuser@HOST_TO> mkdir ~/.ssh
335 someuser@HOST_TO> touch ~/.ssh/authorized_keys
336 someuser@HOST_TO> chmod 700 ~/.ssh
337 someuser@HOST_TO> chmod 600 ~/.ssh/authorized_keys
338
339 (2.3) Put two rows from previons step (content of /root/.ssh/id_rsa.pub,
340 /root/.ssh/id_dsa.pub from HOST_FROM) into the ~/.ssh/authorized_keys
341
342 (3) Test of public key authentication:
343
344 As root@HOST_FROM, try:
345
346 root@HOST_FROM# ssh someuser@HOST_TO
347
348 you will logged as 'someuser' to 'HOST_TO', without password.
349
350 (4) If step 3 successful, configure fsbackup on HOST_FROM for store
351 backup to repository on HOST_TO.
352
353 NOTE: you not need to install and run fsbackup on HOST_TO.
354 (4.1) Make repository on HOST_TO owned by 'someuser' and set permissions:
355
356 someuser@HOST_TO> mkdir ~/backup_from_HOST_FROM
357 someuser@HOST_TO> chmod 700 ~/backup_from_HOST_FROM
358
359 (4.2) Configure fsbackup on HOST_FROM:
360
361 root@HOST_FROM# joe /usr/local/fsbackup/my_backup1.cfg
362
363 change next rows:
364
365 $cfg_type = "remote_ssh";
366 $cfg_remote_host = "HOST_TO";
367 $cfg_remote_login = "someuser";
368 $cfg_remote_path = "/home_of_someuser/backup_from_HOST_FROM";
369
370 (4.3) run the fsbackup and check result:
371
372 root@HOST_FROM# /usr/local/fsbackup/create_backup.sh
373 someuser@HOST_TO> ls -l ~/backup_from_HOST_FROM/
374
375 (4.3) dont forget to place to /etc/crontab on HOST_FROM next row for everyday backup:
376
377 1 1 * * * root /usr/local/fsbackup/create_backup.sh
378
379 > Q: Do you have any script to test if the backup completed successfully
380 > every day ? I want to plug that script into my nagios so that I know that the
381 > backup happened everyday. So if I run the backup script everyday, I can have
382 > this script check for it. If for any reason, the backup failed, my nagios will
383 > alert me.
384
385 A: Hmm.. if you have fsbackup runned from /etc/crontab as root, as
386 described above, cron will send to root all output of script as mail
387 every day. It is most full method of backup control, because logical
388 mistakes are possible, as empty directories or missed directories to
389 backup, etc. But if you want to trace some certain moments, tell me and
390 we will try to resolve it.
391
392 > Q: I forgot one small thing. One of my systems has mysql on it. You mentioned this:
393 > - if we dont want to backup databases and sysconfigs. Otherwise, we
394 > must edit scripts/* too. Write me pls if you want it.
395 >
396 > Would it be too difficult to give me instructions to backup mysql databases ?
397
398 A: For setup to backup mysql database, we need to:
399
400 (1) edit /usr/local/fsbackup/scripts/mysql_backup.sh:
401
402 row 17: backup_name="some_name"
403
404 row 43: backup_method="full" - all databases
405
406 row 52: backup_db_list - list of databases - not used if
407 backup_method="full", aplied if backup_method= "db" or "notdb"
408
409 row 61,62: backup_mysqluser,backup_mysqlpassword - auth information for MySQL
410
411 row 73: backup_path - mysql backups will be placed here.
412
413 row 81: backup_progdump_path="/usr/local/bin" - path to "mysqldump"
414
415 row 93: extra_mysqldump_flag="--complete-insert" - extra mysqldump
416 flags. See man mysqldump to find what you want.
417
418 (2) edit the backup run script, /usr/local/fsbackup/create_backup.sh:
419 joe /usr/local/fsbackup/create_backup.sh
420 in line 42, set:
421 backup_mysql=1
422
423 (3) test your mysql_backup script:
424 /usr/local/fsbackup/scripts/mysql_backup.sh
425 and all system:
426 /usr/local/fsbackup/create_backup.sh
427
428
429 > Q: Also, what do you mean by "sysconfigs" ?
430
431 A: As sysconfigs here is meant are information about installed packages,
432 for opportunity to quick restore all non-system (installed by packages)
433 services.
434
435
436 > Q: I am backing up /etc directory. Are there system configs besides /etc directory ?
437
438 A: Some thrid-party services stored config files in /usr/local/etc dir
439 too. And there are some important config data which stored in Linux in
440 /var, as named's zone files.
441