Thursday, 13 March 2014

This blog is about using rsync with sshfs. I am using Debian 6 as the local system and a VPS of Debian 6 x86_64 as the remote system.

To begin with, we will just use sshfs to mount a remote directory locally.


First off, you need a ssh server [/client] installed on remote system and a ssh client on the local machine. I'm assuming your installations already have both installed.


on local system install sshfs
[as root]
     apt-get install sshfs
they say do,
     modprobe fuse
For me it doesn't seem to do anything, but I recommend running the command anyway.

if you are going to do everything as root, you're good to go, otherwise add a user to the fuse group;
     usermod  -a -G fuse newuser     [user exists and is newuser]
Create a directory where you can mount the remote file system.
     mkdir /tmp/eclectica  [ I 'm making a directory /eclectica in /tmp ]
mount the remote directory
     sshfs remoteuser@eclectica.mx:/home/remoteuser /tmp/eclectica -p 1022
     [ explanation;
          I'm using account remoteuser on the remote system,
               eclectica.mx
          and mounting "/home/remoteuser", the remote users home directory
          to /tmp/eclectica
          The ssh port on eclectica is 1022.]

It will ask for the password for remoteuser on the remote system.

The accounts, and permissions can be a little confusing, but essentially:
     * the locally used account needs full access to the directory you mount to.
     * the remote account needs access to the directory you are mounting.

when done, un-mount it with;
     fusermount -u /tmp/eclectica



Now, to use an sshfs mounted directory and rcync to backup a remote system.

The machine I am backing up to is the local machine, and the machine I'm backing up is the remote machine, which in this example is eclectica.mx;

On the local machine;
install rsync.
     apt-get install rsync
create a backup directory
     mkdir /backups
create a mount point directory
mkdir /root/eclectica
mount the remote file system
     sshfs root@eclectica.mx:/ /root/eclectica -p 1022
[you are using the remote root account to mount the local file system into the local root accounts home directory]

We are now ready to do a rsync backup of the remote system
     rsync -av /root/eclectica /backups
[note; it may not be able to access and backup files and directories that are locked.]

When backup is complete, un-mount with;
     fusermount -u /root/eclectica

Isn't that cool!


My other blogs:
OpenVZ on Debian                -  http://openvzondeb.blogspot.ca/
Linux Server Hardening        -  http://linuxserverhardening.blogspot.ca/
Icecast on Debian                  -  http://icecastondebian.blogspot.ca/2013/10/page-one_31.html
SSHFS with rcync                 -  http://usingsshfs.blogspot.ca/
SOCKS Tunneling                 -  http://sockstunneling.blogspot.ca/ 
Kobo Arc 7", 64GB               -  http://koboarc.blogspot.ca/ [*new*]
and, a few works in progress:
Short Stories                          -  http://louisebridgewrites.blogspot.ca/
Android TV Sticks                -  http://tvsticks.blogspot.ca/


My Streams:
Ices information panel          -  http://www.eclectica.mx:8000/

One of my streams is an all Neil Young stream.To see its listing on the Icecast Directory [at:  http://dir.xiph.org/ ] search for Neil.
The search results will be: Neil Young [x listeners] " All Neil Young, and only Neil Young."

[all links in this article worked as of 2014/03/25 ]