Backing up a FreeBSD system

Martin Schweizer pcservi at spectraweb.ch
Sun Oct 24 21:41:14 PDT 2004


Hello Steve

I copied once a week my filesystems /, /usr and /var to a second hard drive 
with the following cron batch (it also mailed my the important files, fstab, 
dmesg.boot and disklabes):

#!/bin/sh
# Definition des Formates für das angehängte Datum
datum=`date "+%Y%m%d"`

# Sendet die Disklabels
/sbin/disklabel ad0 | /usr/bin/mail -s ad0_disklabel your at isp.com
/sbin/disklabel ad2 | /usr/bin/mail -s ad2_disklabel your at isp.com
# Sendet fstab
/usr/bin/mail -s fstab your at isp.com < /etc/fstab
# Sendet dmesg.boot
/usr/bin/mail -s dmesg.boot your at isp.com< /var/run/dmesg.boot

# Löschen der bestehenden Dateien
/bin/rm /disk2/backup/*.dmp

# Dump wird erstellt. Wenn nicht erfolgreich (-> exit codes), 
# wird ein Mail an your at isp.com versendet
/sbin/dump -0au -f /disk2/backup/usr_$datum.dmp /usr || /usr/bin/mail -s Backup-Fehler your at isp.com
/sbin/dump -0au -f /disk2/backup/var_$datum.dmp /var || /usr/bin/mail -s Backup-Fehler your at isp.com
/sbin/dump -0au -f /disk2/backup/root_$datum.dmp / || /usr/bin/mail -s Backup-Fehler your at isp.com

# Exitcode
exit 0

Hope, this helps.

Am Mon, Oct 18, 2004 at 10:30:45AM -0400 Steven J Corso schrieb:
> 
> 
> I would like to utilize dump to back up my filesystems on a FreeBSD
> machine.  I happen to be utilizing FreeBSD current at this time.
> 
> I would like to do this from single user state on the system.
> 
> I have made this work, and the restore as well to another disk drive,
> which is great.
> 
> However, I would like to have the system check and see if I want this to
> happen at a specific time, and do the backup, and then return to
> multi-user state.
> 
> I think I did this a long time ago under BSD/OS.
> 
> I did it something like this:
> 
> 1.  Set a cron job to check for the existance of a file (like
> want.backup).
> 
> 2.  If no want.backup, do nothing
> 
> 3.  If want.backup, then "init 1", backups, reboot.
> 
> There are a couple of things I can not figure out:
> 
> 1.  How do you get a FreeBSD system into sigle user state and start a
> shell without the prompt from init?
> 
> 2.  When the system goes into single user state how do you get it to
> execute a script?
> 
> Any help would be greatly appreciated.

-- 

Regards

Martin Schweizer
<info at pc-service.ch>

PC-Service M. Schweizer GmbH; Gewerbehaus Schwarz; CH-8608 Bubikon
Tel. +41 55 243 30 00; Fax: +41 55 243 33 22; http://www.pc-service.ch;
public key : http://www.pc-service.ch/pgp/public_key.asc; 
fingerprint: EC21 CA4D 5C78 BC2D 73B7  10F9 C1AE 1691 D30F D239;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20041024/abec9145/attachment.bin


More information about the freebsd-questions mailing list