Results 1 to 8 of 8

Thread: Backups Using tar: which directories to exclude?

  1. #1
    Join Date
    Jan 2007
    Location
    /bunk
    Beans
    194
    Distro
    Kubuntu 8.10 Intrepid Ibex

    Backups Using tar: which directories to exclude?

    Hello all,

    I'm trying to write a script to back up my system using tar, and I'm wondering which directories I should exclude. So far, I'm planning on excluding /dev, /mnt, /media, /proc, /etc/fstab, /sys, /var/run and /etc/acpi. The goal is to enable me to extract my tarball over a fresh install of gutsy, in case I blow up my system.

    Am I missing any that would cause me problems if they overwrote a newer version?

  2. #2
    Join Date
    Jun 2006
    Location
    Solihull, UK
    Beans
    1,413

    Re: Backups Using tar: which directories to exclude?

    Quote Originally Posted by russlar View Post
    Hello all,

    I'm trying to write a script to back up my system using tar, and I'm wondering which directories I should exclude. So far, I'm planning on excluding /dev, /mnt, /media, /proc, /etc/fstab, /sys, /var/run and /etc/acpi. The goal is to enable me to extract my tarball over a fresh install of gutsy, in case I blow up my system.

    Am I missing any that would cause me problems if they overwrote a newer version?
    You've got it pretty much spot-on. I've used this method successfully several times (and restored a whole system using it), and I exclude any virtual or temporary filesystems. The ones I exclude are /dev, /proc, /sys, /tmp, /var/run and /var/lock. I also exclude /home from my tar backups, as I backup this using a separate regime.

    You obviously have to remember to recreate these on a restored system though.

    Why the need to exclude /etc/fstab, /etc/acpi, /mnt and /media though? /etc/fstab and /etc/acpi will both be useful when restoring from a backup. I would include /media and /mnt if they are empty at the time of backup, as it removes the risk of you forgetting to recreate these folders when you restore from it.

    This is the guide I followed initially: http://ubuntuforums.org/showthread.php?t=81311

  3. #3
    Join Date
    Jan 2007
    Location
    /bunk
    Beans
    194
    Distro
    Kubuntu 8.10 Intrepid Ibex

    Re: Backups Using tar: which directories to exclude?

    Quote Originally Posted by chrisccoulson View Post
    Why the need to exclude /etc/fstab, /etc/acpi, /mnt and /media though?
    Because I'll be doing my restore to a fresh install, which may (or may not) have different hardware and HDD configurations.

  4. #4
    Join Date
    Jun 2006
    Location
    Solihull, UK
    Beans
    1,413

    Re: Backups Using tar: which directories to exclude?

    Thanks for the clarification. That definately makes sense for /etc/fstab, but I think /etc/acpi is common between machines using different hardware. I don't think any of the files are customized for different hardware. They all come from the acpi-support package (correct me if I'm wrong though)

  5. #5
    Join Date
    Jan 2007
    Location
    /bunk
    Beans
    194
    Distro
    Kubuntu 8.10 Intrepid Ibex

    Re: Backups Using tar: which directories to exclude?

    ok, so I gave it a shot:

    Code:
    root@HAL-ubuntu:/# tar -cvvfjp sysbackup.tar.bz2 --exclude='/proc/*' --exclude='/sys/*' --exclude='/etc/fstab' --exclude='/media/*' --exclude='/dev/*' --exclude='/mnt/*' --exclude='/etc/grub.conf' --exclude='/var/run' --exclude='/2.5sata/*' --exclude='/home/rgillette/*' --exclude='/sysbackup.tar.bz2' /
    I end up with a file called jp, and the last line of the very verbose output is something along the lines of Error: exited from previous errors.

    Judging by the size of the jp file, it is the right size, but the wrong name. I'm using the -j and -p options to use bzip2 and keep permissions.

    Jaunty Jackalope, because we feel bad for that other guy from Full House.

  6. #6
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Backups Using tar: which directories to exclude?

    Your like me - as in stuffing up the tar options order; Try this '-cvvjpf'

  7. #7
    Join Date
    Jun 2006
    Location
    Solihull, UK
    Beans
    1,413

    Re: Backups Using tar: which directories to exclude?

    Yes, the 'f' has to be the last option, because it takes 'sysbackup.tar.bz2' as a parameter I think. Hence why you ended up with an archive called 'jp' the first time.

  8. #8
    Join Date
    Jan 2007
    Location
    /bunk
    Beans
    194
    Distro
    Kubuntu 8.10 Intrepid Ibex

    Re: Backups Using tar: which directories to exclude?

    Good call.

    I wound up using rsync instead.
    Jaunty Jackalope, because we feel bad for that other guy from Full House.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •