OpenBSD Journal

Backing Up

Contributed by jose on from the CYA dept.

Back in grad school, my laptop died with my thesis on it. I hadn't saved it anywhere, so you can imagine that was a pretty scary moment. Since then, I really learned to keep backups of even my personal stuff. A few resources which round out an earlier story are out to help you figure out how to use some more archiving tools.

Using the pax tool was one of the latest BSD pieces on the OnLamp site.

A brief rsync tutorial also gives some example scripts for backing up your system. As a reference, my brief "backup" command is just a small shell script:

#!/bin/ksh
export RSYNC_RSH=/usr/bin/ssh
rsync -avz ~/* --exclude music/ jose@192.168.0.11:~/rsync/tank/
Keep your data safe!

(Comments are closed)


Comments
  1. By dash () on

    This is my personal script.
    ##################################
    #!/bin/sh
    today=$(date +%m%d)
    OPT="--delete --stats"

    cd /home/rsync_log/

    echo "Backup start" | mail -s "Backupstart" dash at foru.sarang.net

    rsync -avz 211.239.150.31::test /Backup/test $OPT 2>&1 > /home/rsync_log/test_$today_log
    .
    .
    .

    echo "Backup Done" | mail -s "Backupdone" dash@foru.sarang.net
    ####################################
    of course, backup server opened rsync port.

    Comments
    1. By Brett Jones () on

      Just for fun.... lets start sending dash "Backup start" and "Backup Done" emails at random time throughout the day.

      Comments
      1. By dash () on

        Yes, I want monitoring All Server. ;-P
        my mistake....I worried about that..

  2. By Pascal Lalonde () plalonde@overnet.qc.ca on mailto:plalonde@overnet.qc.ca

    I do my backups this way:
    /usr/local/bin/gtar zcvf /var/cd_image/backup.tar.gz -T /etc/bkinclude -X /etc/bkexclude >> $BKLOG 2>&1

    The contents of bkinclude are:
    /etc/
    /home/
    /root/
    /cvs/
    /var/named/
    /var/www/
    /var/backups/
    /var/log/
    /usr/local/

    and bkexclude:/etc/
    /home/mp3share
    /home/pub

    The cd_image directory is later picked by cdrecord, on a CD-RW. (This is my "home server", my personnal data is in /home).

    I don't know if this is a good way to do backups, but until now it worked very well. But I'd gladly accept suggestions.

    Comments
    1. By Anonymous Coward () on

      you dont backup crontabs or mail or even your kernel.

      the problem with not backing up everything is forgetting what to include, so specify only what to exclude, not what to include.

      Comments
      1. By Pascal Lalonde () plalonde@overnet.qc.ca on mailto:plalonde@overnet.qc.ca

        The problem is, I only have 650-700megs of backup space. As I said, this is my personnal server (at home), so I can't afford a SCSI tape or some other big backup media for that.

        I don't mind having to spend 2 days rebuilding it. I just want to be able to get all my personnal data back, and configuration data. My backup already takes 340 megs, gzipped. And it could grow very fast. My mail resides under /home, Maildir format. For crontabs, I guess I should add /var/cron/tabs. Maybe I could be more "general" in what I include, and exclude what I don't need. For example, include /var, but exclude /var/cd_image.

  3. By Anonymous Coward () on

    rsync -avz ~/* --exclude music/ jose@192.168.0.11:~/rsync/tank/

    hrm, the only thing i really *cant* reproduce is the music i have on my servers....

  4. By RC () on

    Am I the only one that uses plain, old-fashioned, dump and restore?

    Comments
    1. By Anonymous Coward () on

      nope it's the best method backing up whole filesystems. I do so too
      greets Dennis

      Comments
      1. By vincent () vincent at igc dot ethz dot ch on mailto:vincent at igc dot ethz dot ch

        could you elaborate?

    2. By Anonymous Coward () on

      I am using it too. I've tweaked an incremental dump strategy that I've found somewhere on the net to a local disk directory, the files are then fetched to multiple other hosts.

      Cheers, Matthias

      Comments
      1. By Anonymous Coward () on

        Could you post a link to that? Or email a description to helge at olsentech dot net

        Thanks in advance :-)

        Comments
        1. By Anonymous Coward () fuc952d at tninet.se on mailto:fuc952d at tninet.se

          http://www.backupcentral.com/hostdump.html

  5. By danny () danny@partisan.de on mailto:danny@partisan.de

    <br> #!/bin/bash <br> <br> ORACLE_HOME=/usr/local/oracle <br> PATH=/bin:/usr/bin:$ORACLE_HOME/bin <br> <br> SERVER_ROOT=/server-root <br> <br> DATE=`date +%Y%m%d` <br> DAY=`date +%a` <br> MDAY=`date +%d` <br> <br> SERVER="dev pre docs svr presse" <br> <br> dev="documents cgi-bin perl sql bin c" <br> pre="documents cgi-bin" <br> docs="documents cgi-bin" <br> svr="documents" <br> presse="documents" <br> <br> if [ $DAY = Fri ] <br> then <br> touch /server-root/.backup <br> for server in $SERVER <br> do <br> eval DIR=$$server <br> cd $SERVER_ROOT/$server <br> tar czf - $DIR | ssh -C -q backup@backupserver "cat > /var/backup/full/svr_$DATE_$server.tar.gz" <br> done <br> exp username/password@ORADB file=/tmp/expdat.dmp full=y <br> gzip /tmp/expdat.dmp <br> scp -Cq /tmp/expdat.dmp.gz backup@backupserver:/var/backup/inc/svrdb_full_$DATE.dmp.gz <br> rm /tmp/expdat.dmp.gz <br> else <br> for server in $SERVER <br> do <br> eval DIR=$$server <br> cd $SERVER_ROOT/$server <br> tar czf - `find $DIR -type f -newer /server-root/.backup` | ssh -C -q backup@backupserver "cat > /var/backup/inc/svr_inc_$DATE_$server.tar.gz" <br> done <br> touch /server-root/.backup <br> exp username/password@ORADB file=/tmp/expdat.dmp owner=svr1 <br> gzip /tmp/expdat.dmp <br> scp -Cq /tmp/expdat.dmp.gz backup@backupserver:/var/backup/inc/svrdb_svr1_$DATE.dmp.gz <br> rm /tmp/expdat.dmp.gz <br> fi <br> <br>

    Comments
  6. By Jim () on

    Anyone get rsync&&ssh running on Windoze? My goal is to use rsync to pull changes from a windoze client via ssh to my openbsd backup machine. In the meantime I thought about making the openbsd machine a smb server and mount the share on the windoze machine, but I don't really want to go there.

    Comments
    1. By Shane () on

      I've run rsync and ssh on Windows 2000. I used an OpenSSH port by Network Simplicity (http://www.networksimplicity.com/openssh/). I forget where I got rsync for Windows, but you should be able to Google for it. The setup was pretty easy, if I remember. I could then rsync stuff through ssh from my OpenBSD box to my Windows box. It was pretty useful.

      Comments
      1. Comments
        1. By Shane () on

          Yes, but the OpenSSH port by Network Simplicity is not designed to run with Cygwin. It uses the Cygwin dll's, but the two clash (so I'm told) if you try to install both. You can get rsync for Windows without installing Cygwin.

  7. By Coward () on

  8. By Coward () on

  9. Comments
    1. By William () on

      I was curious if you actually built this on OpenBSD. It looks interesting, but I have not been able to build it on -current.

      Comments
      1. By Anonymous Coward () on http://www.cis.upenn.edu/~bcpierce/unison/

        I had no problem compiling it in -stable. What I have done :

        1 - download latest ocaml compiler : http://caml.inria.fr/
        2 - install ocaml
        3 - download unison source file
        4 - compiling it

        Comments
        1. By William () on

          I installed ocaml 3.06 from ports and followed the same procedure from there, but no deal. I guess I'll mess with it some more.

          Comments
          1. By William () on

            Never mind. I just realized that I needed to compile with gmake since I have not replaced make with gmake.

  10. By Jedi/Sector One () j@pureftpd.org on http://www.pureftpd.org/

    When you got plenty of sub-directories, rsync crawls like hell, takes all the available cpu+memory+swap, and crash. Even backuping 40gigs with rsync doesn't seem possible.

    I switched to ssync, a lightweight tool to sync two (locally mounted) directories. It works extremely well and fast for backups.

  11. By Kyle Amon () amonk@backwatcher.com on http://www.backwatcher.com/

    Some might like to check out DataCrypt-0.10.tar.gz
    at...

    http://www.backwatcher.org/index.php?page=software

    It is a perl program (with a couple config files) for making efficient, secure backups of large numbers of remote unix machines with rsync over ssh.

    It could be made to backup winblows machines too, but since I have no need for that, I never bothered with it. It's GPLd, so add that if you like. :-)

    BTW, there is very little documentation in that tarball at present, but then if you need more than that, you probably need to backup winblows machines easily anyway. :)

    Later,

    -- Kyle

Latest Articles

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]