Results 1 to 5 of 5

Thread: [HOW TO] Back up your data on to a shared network drive

  1. #1
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    [HOW TO] Back up your data on to a shared network drive

    This should work on any version of Linux, although it has only been tested on (Ubuntu) Jaunty Jackalope and (Ubuntu) Karmic Koala.

    If using on a non-Debian Linux system, the commands here given for installing the software are not applicable. Please consult your distribution if you do not know how to install software.

    I am going to show you how to back up your home directory (/home/username) to a remote drive shared on the network (ex. Lacie Ethernet BigDisk - 1TB) along with a list of installed packages and a list of sources.
    Prerequisites:
    Step 1: Open up a Terminal window (Applications->Accessories->Terminal - don't be afraid ) and keep it open for the duration of this tutorial.

    Step 2: Paste the following code into the Terminal window:
    Code:
    sudo aptitude install smbclient smbfs
    Setting up the backup:
    Step 1: Configure your network drive properly and make sure you can connect to it from the computer you wish to back up. Also record the IP Address of the network disk. I am sorry, but I cannot help you set up your network drives. There may be threads on the forum that can help you if you are having problems.

    Step 2: Create the mountpoint for the backup drive by pasting the following into the Terminal window you left open:
    Code:
    sudo mkdir /mnt/backup
    Step 3: Open up a new Text Editor window (Applications->Accessories->Text Editor)

    Step 4: Copy the code below into the Text Editor window and save it as a shell script (File->Save As...->Select shell script as the file type):
    Code:
    #!/bin/bash
    cd
    yes "your password here" | sudo -S cp /etc/apt/sources.list .
    dpkg --get-selections > installed-software 
    yes "your password here" | sudo -S smbmount //IP address/share name /mnt/backup -o username=username,password=password,uid=1000,mask=000
    #username and password are optional, so only input them if necessary.
    rsync -arquz --exclude=Music --exclude=Videos --exclude=Pictures --exclude=Dropbox --exclude=Examples --exclude=.VirtualBox --exclude=.beagle --exclude=.cache --exclude=.icons --exclude=.evolution --exclude=Skype\ Calls --exclude=tabla\ lessons --exclude=.thumbnails --delete /home/chiraag /mnt/backup/
    yes "your password here" | sudo -S smbumount /mnt/backup
    exit
    Rsync options: a = archive (not sure what this does , but leave it on), r = recurse into directories, q = quiet (recommended - otherwise your Terminal window will fill with junk ), u = update (skip files that haven't been changed), z = compress (makes network backups faster, recommended)

    Step 5: replace the bolded items only!!!!! with appropriate values. For the rsync options, I would just change which paths you want excluded and maybe remove the
    Code:
    --delete
    option. Keep in mind, if you delete the
    Code:
    --delete
    option, no files deleted on your computer will be deleted on the back up hard disk!!! This can lead to unnecessary bloating of your backup.
    Finally, make the script executable with
    Code:
    sudo chmod +x /path/to/backup/script/you/just/created
    Replace /path/to/backup/script/you/just/created with the actual path. To figure out this path, go to Places->Home and browse to the folder which contains the script. Then, click on the little icon next to the buttons which show where you have been (the tooltip should say something pertaining to location). The full path should be shown with slashes (/) between folder names. Copy this long thing and paste it into the terminal instead of the /path/to/backup/script/you/just/created.

    Step 6 [optional]: Install "Scheduled Tasks" with
    Code:
    sudo aptitude install gnome-schedule
    (paste the code into the Terminal window) and schedule your backup script to run however often you wish!

    TO RESTORE: Simply change the rsync command in the script to read
    Code:
    rsync -arquz --delete /mnt/backup/ /home/chiraag
    KEEP IN MIND: IF YOU KEEP THE --delete OPTION, IT WILL DELETE ALL FILES THAT WERE NOT BACKED UP. PLEASE TAKE CAUTION WHEN USING THIS WITH THE RESTORE SCRIPT. That's all, folks!
    - Chiraag
    Last edited by chaanakya_chiraag; September 16th, 2010 at 11:52 PM.
    Use Dropbox! Sign up using this link: http://www.dropbox.com/referrals/NTEyMzg5Nzc5 and get free space!!
    Registered Linux User #525815
    Check out Musik - a FOSS text-to-music converter!

  2. #2
    Join Date
    Dec 2008
    Location
    /home
    Beans
    163
    Distro
    Ubuntu Development Release

    Re: [HOW TO] Back up your data on to a shared network drive

    Nice howto,

    If I wasn't having any problems connecting to my samba server using smbmount, i'd definatly use it!

    I've bookmarked it just in case the server decides to start working the way i want it to XD

  3. #3
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [HOW TO] Back up your data on to a shared network drive

    Thanks! Is there anything even remotely confusing (especially from the eye of a beginner)? I want to make sure that nothing is ambiguous
    - Chiraag
    Use Dropbox! Sign up using this link: http://www.dropbox.com/referrals/NTEyMzg5Nzc5 and get free space!!
    Registered Linux User #525815
    Check out Musik - a FOSS text-to-music converter!

  4. #4
    Join Date
    Dec 2008
    Location
    /home
    Beans
    163
    Distro
    Ubuntu Development Release

    Re: [HOW TO] Back up your data on to a shared network drive

    It kept giving me syntax errors until i removed
    needed to access network drive (if applicable)
    I recommend putting that on a separate commented out line.

    Other than that the script works really well, I keep getting permission errors, but thats the fault of the server. I'd defiantly recommend this to other users.

  5. #5
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [HOW TO] Back up your data on to a shared network drive

    Thanks! I'll do that ASAP
    - Chiraag
    Use Dropbox! Sign up using this link: http://www.dropbox.com/referrals/NTEyMzg5Nzc5 and get free space!!
    Registered Linux User #525815
    Check out Musik - a FOSS text-to-music converter!

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
  •