Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
is there anything I can buy to keep a backup of my hard drive? I would like something that will keep an updated copy of my hard drive, so in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8

    backup drive


    is there anything I can buy to keep a backup of my hard drive?

    I would like something that will keep an updated copy of my hard drive, so in case something happens I could go buy a new drive, restore what was on the old one and be up and running quickly.

    I know I could get an external drive and periodically clone my drive onto it, but I would like something that would only update what has changed, and something that will do it automatically (this is not necessary, but would be nice).

    By the way, I have a 500 GB drive, but only really need to keep a 150 GB partition backed up.

    Thanks
    David

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    You could write a bash script using the find command with mtime or ctime parameters to find files modified/changed within a certain period of time and include a backup section in the script to copy the files modified/changed. You could then put an entry in cron to regularly run the script.

    I don't know how much good this will do if you are backing it up to another partition on the same drive and the drive goes to hell??

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8
    Thanks... I am thinking of getting a separate external drive to back it up on...

    But your explanation went over my head. I am sure it is easy, but I have never done a script, or used cron.

    If I did something like that, would it be easy to restore a drive, or do I need an image?

    Thanks again.

  4. #4
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8
    and one other thing... I run windowsxp inside virtualbox, so I need everything in there backed up too. I don't know if that is more difficult or not...

    I would like it if there was a backup drive that was programed to just keep the drive backed up.

    or maybe I could use an online service, like kriptonit or something, but I don't think they work with lilnux...

  5. #5
    Just Joined!
    Join Date
    Sep 2007
    Location
    Lafayette, IN
    Posts
    83
    Quote Originally Posted by davidwillis View Post
    I know I could get an external drive and periodically clone my drive onto it, but I would like something that would only update what has changed, and something that will do it automatically (this is not necessary, but would be nice).
    The rsync command is your friend in this case. I'll share with you the backup script that I run to make a backup of my /archive directory. (slightly modified to be more generic)

    Code:
    #!/bin/csh -f
    
    set disk=/dev/sdd1
    
    echo Mounting $disk
    mount $disk /backup
    
    rsync -av --stats --delete /archive /backup
    
    umount /backup
    So what does this code do? Well it mounts the disk I specify, which happens to be a USB drive. It runs the rsync command (which I'll explain in depth below), and then unmounts the directory. So what does the rsync do?

    -av Tells rsync to use archive mode, which means it copies subdirectories and preserves permissions and timestamps. The v means to be verbose, or print a list of all the files, plus some other information
    --stats Tells rsync to print some stats at the end: how much data was copied, how many files, etc
    --delete Tells rsync to delete any files in the "to" directory (/backup) that don't exist in the "from" directory (/archive)
    /archive Is the directory I'm backing up
    /backup Is the directory I'm writing the backup to.

    So I run my script by hand every few nights. However you could use automate it with cron. cron is the system that runs processes at scheduled times. See the crontab man page for more information, but an example entry might look like

    Code:
    0 0 * * * /path/to/your/backup/script
    This would cause the script to be run at midnight every night.

  6. #6
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8
    Thank you so much... that is perfect.

    a couple questions though.. if I put in /hda5, instead of /archive, would that back up the entire partition?

    then how would I restore the partition if the hard drive crashed... I am thinking I could boot into a live cd, and mount a new hard drive and the usb hard drive... then would I use the rsync again just in reverse to get it onto the new hard drive? Then I would just need to put grub on and it should boot just like before right?

    Thanks again... this is very helpful.

    ps. That brings up one more question... how do I put grub back on... can I do that from a live cd? I think I can, but have never done it, I have just let the installer install grub.

  7. #7
    Just Joined!
    Join Date
    Sep 2007
    Location
    Lafayette, IN
    Posts
    83
    Quote Originally Posted by davidwillis View Post
    Thank you so much... that is perfect.

    a couple questions though.. if I put in /hda5, instead of /archive, would that back up the entire partition?
    I believe you need to use the mount point (e.g. /archive) and not the partition. I've not tested it the way you suggested, but I don't think it would work as expected. You can add some flexibility to the rsync command to make it meet your needs. The rsync man page does a good job of explaining the many options available.

    then how would I restore the partition if the hard drive crashed... I am thinking I could boot into a live cd, and mount a new hard drive and the usb hard drive... then would I use the rsync again just in reverse to get it onto the new hard drive? Then I would just need to put grub on and it should boot just like before right?
    That's right.

    ps. That brings up one more question... how do I put grub back on... can I do that from a live cd? I think I can, but have never done it, I have just let the installer install grub.
    That's one of the more common things to do with a rescue CD. This page Reinstalling GRUB has good instructions for a variety of situations.

  8. #8
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8
    Thank you very much.... I will do some reading, and get a usb drive and see if I can get it to work...

  9. #9
    Just Joined!
    Join Date
    Apr 2009
    Posts
    8
    Ok, I got my drive, and wrote my script.
    set disk=/dev/sdi1

    echo Mounting $disk
    mount $disk /backup

    rsync -av --stats --delete / /backup

    umount /backup
    I also made it executable by doing this

    chmod a+x ./dailybackup

    I am testing it now, but am getting some errors: I was going to copy and past them, but I missed them... but they were permision errors 13....

    I will run it again when it is done and get the exact error.

    Edit: I just got to thinking... with it cause a problem using / as the source, since /backup is in there... will it get stuck in a loop?

  10. #10
    Just Joined!
    Join Date
    Sep 2007
    Location
    Lafayette, IN
    Posts
    83
    Quote Originally Posted by davidwillis View Post
    Edit: I just got to thinking... with it cause a problem using / as the source, since /backup is in there... will it get stuck in a loop?
    It might, I've not tried it that way before. At any rate, it would be fairly pointless. You should add an --exclude to your rsync command (something like --exclude="/backup" perhaps. See the rsync man page for more info).

Page 1 of 2 1 2 LastLast

Posting Permissions

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