Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Using tar to backup home directory

  1. #1
    Join Date
    Apr 2005
    Location
    Lancaster, PA
    Beans
    166
    Distro
    Ubuntu Breezy 5.10

    Using tar to backup home directory

    sorry, i wasn't sure exactly where to post this, so mods feel free to move it where appropriate.

    i want to use tar to backup my home directory, but i have a little discrepancy i want to solve before i actually test it out. here is the command:

    tar -cvzf ~/backup.tar.gz ~/

    that will make the file backup.tar in my home directory, and uses my home directory as the backup source. will this work with no problems? i can't shake the feeling that it wouldn't work because the .tar.gz file is being created in the directory that is being tar'd.

  2. #2
    Join Date
    Sep 2006
    Location
    European Union, Portugal
    Beans
    Hidden!
    Distro
    Ubuntu 6.10 Edgy

    Re: Using tar to backup home directory

    Well, try it and you'll find out.

    Make a directory with a couple of files and try to tar it from within.

    I'm almost sure it will work, but you can't be sure until your try it

  3. #3
    Join Date
    Apr 2005
    Location
    Lancaster, PA
    Beans
    166
    Distro
    Ubuntu Breezy 5.10

    Re: Using tar to backup home directory

    derr... good suggestion on trying it out. i even tested tar out earlier to see if it would get hidden .whatever folder and keep their hiddenness by default. why did i not think of this??

    well here goes!

    <edit> well i tried it out, the last two lines of output were this:
    /home/andrew/testing/testing.tar.gz
    tar: /home/andrew/testing/testing.tar.gz: file changed as we read it

    and when i tried to open it with ark, it just crashed right away. i guess i have to create it somewhere else and then copy it back to my home directory.
    Last edited by raublekick; October 10th, 2006 at 12:24 AM.

  4. #4
    Join Date
    Mar 2006
    Location
    UK
    Beans
    4,368
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Using tar to backup home directory

    use rsync instead.

  5. #5
    Join Date
    Nov 2005
    Location
    Toronto
    Beans
    1,181

    Re: Using tar to backup home directory

    Or something like this:

    tar -cvzf /tmp/backup.tar.gz ~/ && mv /tmp/backup.tar.gz ~
    But I mean no harm nor put fault
    On anyone that lives in a vault
    But it's alright, Ma, if I can't please him.

  6. #6
    Join Date
    Apr 2005
    Location
    Lancaster, PA
    Beans
    166
    Distro
    Ubuntu Breezy 5.10

    Re: Using tar to backup home directory

    Quote Originally Posted by ComplexNumber View Post
    use rsync instead.
    eh? can rsync make tar.gz archives? what i want to do has nothing to do with networks either.


    but i also just realized that tar has a --exclude=PATTERN flag, so i can probably just exclude the archive i am making

    tar -cvzf testing.tar.gz --exclude=testing.tar.gz /home/andrew/testing
    did the trick
    Last edited by raublekick; October 10th, 2006 at 12:34 AM.

  7. #7
    Join Date
    Apr 2005
    Location
    Lancaster, PA
    Beans
    166
    Distro
    Ubuntu Breezy 5.10

    Re: Using tar to backup home directory

    things i just learned:

    1. if i'm going to backup my home directory, i should throw my ripped CDs onto my external hard drive where they belong

    2. in the script i am making, i should be sure to exclude all files beginning with "backup" and ending in ".tar.gz"

    3. i should also exclude all files ending in ".iso"

  8. #8
    Join Date
    Apr 2005
    Location
    Parts Unknown
    Beans
    9,213
    Distro
    Ubuntu Development Release

    Re: Using tar to backup home directory

    Here's a sample of what I do.

    Code:
    tar cvpzf /home/matt/backup-matt/20061010home.tgz --exclude=/home/matt/music --exclude=/home/matt/.Trash --exclude=/home/matt/backup-matt --exclude=/home/matt/.thumbnails --exclude=/home/matt/vmware  /home/matt
    The backs up my /home into /home/matt/backup-matt as 20061010home.tgz and excludes my mp3's, thumbnails cached on the drive, and my very large /vmware folder with different distros I'm playing with.

    To exclude a specific type of file in a specific directory use --exclude=/directoryname/*.file-extension

    Play with it a while and you'll get the idea.
    what's a troll? | my blog | my writing | Ubuntu Unleashed

    Don't ask support questions in PMs--post a thread so everyone can benefit!

  9. #9
    Join Date
    Oct 2005
    Location
    EU
    Beans
    40

    Re: Using tar to backup home directory

    Yeah, look at Matt's example! It is ESSENTIAL to notice that Matt uses "p" command line parameter with tar command (p=permissions).

    This ensures that the files will have the right permissions when you extract the tar archive.

    "tar" comes from "tape archive" - so it's been used to make backups of Unix systems for many, many years. I myself took full backup of my Linux system with tar and when I tested it (extracted the tar archive to a new hard drive) everything worked. However, full system backup with tar was made when I had rebooted the computer with Live CD so the system was not in use when I created the tar backup of it.
    Coexist!

  10. #10
    Join Date
    Apr 2005
    Location
    Lancaster, PA
    Beans
    166
    Distro
    Ubuntu Breezy 5.10

    Re: Using tar to backup home directory

    Quote Originally Posted by matthew View Post
    Here's a sample of what I do.

    Code:
    tar cvpzf /home/matt/backup-matt/20061010home.tgz --exclude=/home/matt/music --exclude=/home/matt/.Trash --exclude=/home/matt/backup-matt --exclude=/home/matt/.thumbnails --exclude=/home/matt/vmware  /home/matt
    The backs up my /home into /home/matt/backup-matt as 20061010home.tgz and excludes my mp3's, thumbnails cached on the drive, and my very large /vmware folder with different distros I'm playing with.

    To exclude a specific type of file in a specific directory use --exclude=/directoryname/*.file-extension

    Play with it a while and you'll get the idea.
    excellent, thanks for the suggestions! does --exclude= accept regular expressions? i see * used a lot, but never anything else.

Page 1 of 2 12 LastLast

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
  •