Find the answer to your Linux question:
Results 1 to 6 of 6
I have a Linux server running Debian 5. I need to get it backed up. I have worked with tar in my past Unix days. I've read that there are ...
  1. #1
    Just Joined! routerdork's Avatar
    Join Date
    Mar 2011
    Location
    Nebraska
    Posts
    5

    Backup to Windows Server

    I have a Linux server running Debian 5. I need to get it backed up. I have worked with tar in my past Unix days. I've read that there are some limitations to tar though since it is intended for tape.

    My server would need to backup to a Windows server share. From ther it will be backed up to an offsite location. Can anyone make a recommendation for what to use? I would like to take a full backup weekly and then a incremental daily.

  2. #2
    Linux Newbie Nagarjuna's Avatar
    Join Date
    Feb 2011
    Posts
    122
    I've been wondering how to do this too.. I would probably write a BASH script and implement it using cron-jobs. The following is just an idea/theory and has not been tested. I would not be surprised if someone could show you a much more efficient method, but I'm hoping this will spark some of your own ideas.

    So, I would begin by sharing a directory on the Windows server and then create a BASH script on your Linux system.

    backup_script.sh
    Code:
    #!/bin/bash
    
    # Mount Windows share to '/mnt' directory
    mount -t cifs -o username=<win-user>,password=<password> //host/share /mnt
    
    # Incremental backup
    INC=`date | grep "Mon"`    # Check if it's Monday
    if [ -z "$INC" ]; then    # If it isn't Monday, perform incremental backup
        tar --create --compress \
            --file=/mnt/backup.tar.gz \    # Location to save tar file to
            --listed-incremental=/var/log/snapshot.snar \    # Incremental snapshot        
             ~/example    # Directory to be backed up    
    else # If Monday, perform full backup
        tar czf /mnt/backup.tar.gz ~/example 
    fi
    
    # Now that files have been archived+compressed to server, unmount CIFS share
    umount /mnt
    You will need to edit the script to better fit your environment.

    Make the script executable to owner and block out all others:

    Code:
    chmod 700 backup_script.sh
    More information on incremental backups using GNU tar, GNU tar 1.26: 5.2 Using tar to Perform Incremental Dumps

    Now, you can create a cron-job to perform your backups. Type "crontab -e" as the Linux user who will perform the mount to setup your cron-jobs:

    crontab -e
    Code:
    00 4 * * * ~/backup_script.sh    # Backup daily at 4:00am
    The above script, in theory, will run everyday at 4:00am. It will mount your Windows share to the /mnt directory of your Linux system. It should check to see if it is Monday. If it isn't, it will perform a incremental backup, keeping track of new/old files using a snapshot file specified in the script. If it is Monday, it performs a full backup.

    This of course is just the Linux side of things. You will need to find a way to backup from Windows onto what ever medium you desire.
    Last edited by Nagarjuna; 03-20-2011 at 06:09 AM.

  3. #3
    Just Joined! routerdork's Avatar
    Join Date
    Mar 2011
    Location
    Nebraska
    Posts
    5
    Thanks. I think this would work. I changed a few things. One big one was that I had to specify "domain=domainname" otherwise it would mount as read only.

    Since I have done that though the backup doesn't complete. It stops at what is shown in the attached picture. I am going to remove the domain part and see if it starts again since that is the only change since it stopped working. If you have any ideas on that I would be very grateful.
    Attached Images Attached Images

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    You cannot backup effectively if you don't know what/why you're backing something up. The /proc filesystem should not be included in backup.

  5. #5
    Just Joined! routerdork's Avatar
    Join Date
    Mar 2011
    Location
    Nebraska
    Posts
    5
    I didn't know that. I don't know Linux very well.
    So that being said what directories would you recommend? The app that runs on this was installed by someone previously so I don't know much about its inner workings.

  6. #6
    Just Joined! routerdork's Avatar
    Join Date
    Mar 2011
    Location
    Nebraska
    Posts
    5
    I got this working. I wanted to verify that I understand what this script is doing before I tweak it anymore.

    It finds the day. Based off the day it determines the type of backup needed (full or incremental). Rinse and repeat.

    Thanks for the help.

Posting Permissions

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