+ Reply to Thread
Results 1 to 3 of 3

Thread: BASH: SSHFS Backup Script

  1. #1
    Jordan Guest

    BASH: SSHFS Backup Script

    This script uses Fuse/SSHFS to mount a remote machine via SSH as a local drive. Once mounted, any file(s) can be copied just like a local drive.

    Code:
    #!/bin/sh
    ##
    # Description: SSH/Fuse mount, backup and umount script. 
    #                  Execute via cron for schedule backups over 
    #                  secure shell.
    #
    # Author: Jordan DeLozier
    # Date: 1-19-2009
    # Usage: ./BackupScript.sh
    #
    # Must run as root
    # Must use SSH Key Authentication for automatic updates
    ##
    
    # For some reason the kernel module doesn't always
    # load on boot. Load it now
    /sbin/modprobe fuse
    
    # Mount the remote SSH machine, if there
    # is an error exit. This prevents the files from
    # being copied to the local machine and using
    # local hard disk space
    #
    # Replace <username>,<server>,/path/to/files/ and /mnt/<dir> with
    # proper values.
    ##
    if (!(/usr/local/bin/sshfs <username>@<server>:/path/to/files/ /mnt/<dir>)); then
            echo "Mount Failed"
            exit 1
    fi
    
    # Copy the Files
    # Using -Ru recursively copies and only copies
    # files that are different from the target. 
    # 
    # Replace /source/files and /mnt/<dir of mount>
    ##
    cp -Ru /source/files/ /mnt/<dir of mount>
    
    # Unmount
    #
    # Replace /mnt/<dir of mount>
    ##
    umount /mnt/<dir of mount>
    Use it, change it, distribute it. Please consider linking back to the source when you do if possible.
    Last edited by Jordan; 06-17-2009 at 01:04 PM.

  2. CODECALL Circuit advertisement

     
  3. #2
    kiddies is offline Programmer
    Join Date
    May 2009
    Posts
    129
    Rep Power
    0

    Re: BASH: SSHFS Backup Script

    its work properly.....hey can u give me an algorithma

  4. #3
    Jordan Guest

    Re: BASH: SSHFS Backup Script

    Huh? Algorithm for what?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [HELP] convert Perl script to Bash shell script
    By Egypte in forum Linux Programming and Scripting
    Replies: 2
    Last Post: 04-24-2011, 05:37 PM
  2. BASH: FTP Put Script
    By Jordan in forum Bash / Shell Scripting
    Replies: 12
    Last Post: 11-11-2009, 10:26 AM
  3. Pidgin Password Recovery Bash Script
    By kresh7 in forum Bash / Shell Scripting
    Replies: 3
    Last Post: 09-18-2009, 04:25 PM
  4. Issue Basic Batch Backup Script
    By lickfrog in forum General Programming
    Replies: 2
    Last Post: 04-28-2009, 12:32 PM
  5. Creating a backup script
    By NeedHelp in forum General Programming
    Replies: 3
    Last Post: 09-07-2006, 03:14 AM

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