Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36

Thread: Simple backup script

  1. #1
    Join Date
    Apr 2006
    Beans
    413

    Simple backup script

    My wife's computer runs 12.04 from a SSD. She keeps her data files on a hdd on the computer and periodically backs them up to a desktop USB drive which she plugs in to do the backup.

    There are data files on the USB drive that do not exist on the hdd, and these need to be retained.

    I would like to know a simple script (or program) that would allow her to plug in her USB drive, then click on an icon on her desktop (or something equally simple), and back up all the new and changed files since the last backup. Ideally, the switches (this probably isn't the right word) on the files will be set each backup so that she does not have to keep track of when she last backed up. Thanks.

  2. #2
    Join Date
    Jan 2009
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Need a simple backup script

    The tool 'rsync' would be ideal for this task.

    Here's a one-liner that'll do it:
    Code:
    rsync -av /home/user/ /media/mountpoint/backup
    This example would backup a user's home directory to a mounted drive.

    Keep in mind that trailing slashes do matter with rsync.

    Hope this helps.

  3. #3
    Join Date
    Apr 2006
    Beans
    413

    Re: Need a simple backup script

    Ubudog, Looks easy enough. Is there any way to turn that into a script that can be started with a desktop icon?

    I am getting more comfortable with the terminal, but it would terrify her.

    Thanks

  4. #4
    Join Date
    Jan 2009
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Need a simple backup script

    Sure, just create a file called, for example, "backup.desktop" and place it in the Desktop directory of your user's home directory.

    An example .desktop file for this script would be something like:
    Code:
    [Desktop Entry]
    Type=Application
    Name=backup script
    Exec=/location/to/script.sh
    Name=Backup
    Then just make the file executable:
    Code:
    chmod +x ~/Desktop/backup.desktop
    Also, make sure that your script is executable as well.

  5. #5
    Join Date
    Apr 2006
    Beans
    413

    Re: Need a simple backup script

    Ok, got some of that.

    In the code that goes in the backup.desktop file, how does that code incorporate the rsync command line in your first reply?

    I am guessing that the answer is in the line

    Exec=/location/to/script.sh
    but I am completely new to scripting and have no idea how these things work.

    Apologies, "Noob" here.

  6. #6
    Join Date
    Jan 2009
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Need a simple backup script

    Yep, it is defined in the Exec line.

    In fact, you could just replace Exec with the rsync command.
    Code:
    Exec=rsync -av /home/user/ /media/mountpoint/backup

  7. #7
    Join Date
    Aug 2013
    Beans
    1,988

    Re: Simple backup script

    I use unison for exactly that purpose, it is in the repository. It has a gui, it is very easy to use. You set up a profile for the matching folders and every time when you plug in the external hard drive, just open the profile and it will sync the differences, then press 'go' to sync (default goes by the latest change. But you have options to override it, say, if you accidentally delete something by default it will delete the other copy as well, so you need to sync in the other direction.. the gui is very intuitive so there is no point to explain now)

    Code:
    sudo apt-get install unison-gtk
    Last edited by monkeybrain20122; February 12th, 2014 at 12:26 AM.

  8. #8
    Join Date
    Apr 2006
    Beans
    413

    Re: Simple backup script

    MB, thanks. That can be my next project as time permits.

    For now, want to keep it simple and get something working for her but getting a little over my head here. I am trying to figure out the "to" portion of the Exec line.

    Gparted shows the USB drive to be /dev/sdg1 and an ntfs partition. Does this mean the USB drive is mounted at /dev/sdg1? The "Viewevice information" shows the path to be /dev/sdg

    Or maybe it is not mounted at all because while the drive shows up in Nautilus, when I click on it nothing happens. Very confused as to why it shows up, but doesn't open up.

  9. #9
    Join Date
    Jan 2009
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Simple backup script

    Usually the mountpoint of a flash drive will be in /media/username.

    You will need to install the ntfs-3g package in order to be able to mount and see ntfs partitions.
    Code:
    sudo apt-get install ntfs-3g
    Alternatively, you could format the drive to FAT32 (make sure you have backups of the data on the drive if you do this).

  10. #10
    Join Date
    Aug 2013
    Beans
    1,988

    Re: Simple backup script

    I have not used rsync but I suppose it is /dev/sdg1 because you want the partition.

    It seems that the command only does one way backup. Does it overwrite the old copy or does it just change files that have been modified? What if you accidentally delete something and want to restore it from the backup (i.e syncing the other way around)? I am sure rsync has options for all these stuffs, it is quite widely used, but I haven't read its manual..

    P.S. I however have never used unison with ntfs. All my drives are in ext4. I don't use Windows and therefore have no reason to use its file system.
    Last edited by monkeybrain20122; February 12th, 2014 at 01:00 AM.

Page 1 of 4 123 ... 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
  •