?

Log in

Backup live (mounted) file system on FreeBSD - Unix-Solution [entries|archive|friends|userinfo]
Unix-Solution

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Backup live (mounted) file system on FreeBSD [Aug. 20th, 2007|06:43 pm]
Unix-Solution

unix_solution

[maximum_value]
Problem: realtime backup live file system on FreeBSD. Slices: root directory, /var and /usr.

Solution:

Simple backup
#!/bin/sh
day=`date "+%w"`
backup_dir="/mnt/backup"
dump="dump -C 8 -Lf -"
if [ "$day" -ne 3 ] && [ "$day" -ne 6 ]; then exit 0; fi # start only for two days of week (start daily by cron)
cd $backup_dir || exit 1
$dump / > root.$day.bkp
$dump /var > var.$day.bkp
$dump /usr > usr.$day.bkp
Restore from backup
cd /mnt/new_mount_point
restore -rf /mnt/backup/xxx.bkp
Backup and gzip
#!/bin/sh
day=`date "+%w"`
backup_dir="/mnt/backup"
dump="dump -C 8 -Lf -"
if [ "$day" -ne 3 ] && [ "$day" -ne 6 ]; then exit 0; fi
cd $backup_dir || exit 1
$dump / | gzip > root.$day.bkp.gz
$dump /var | gzip > var.$day.bkp.gz
$dump /usr | gzip > usr.$day.bkp.gz
Restore from gzip backup
cd /mnt/new_mount_point
gunzip /mnt/backup/xxx.bkp.gz | restore -rf -

PS: If you want to do live backup on Linux you can use LVM+snapshot system.
linkReply