Joyent

Translations of this page:

Syncing your files to Connector Strongspace using rsync

If you're using any unix-based OS (Linux, OS X, Solaris, etc), it's quick and easy to keep your data backed up on your Joyent Connector using a simple rsync script. This can be handy in case of catastrophic data loss, unintended overwriting, or even for just looking up a file while on the road. The only requirements are the ability to create a simple script, an SFTP client, and an installed and functioning copy of rsync!

Preparation
  1. Log in to your Connector Strongspace using your SFTP client –> host: strongspace.joyent.net, user: <you>@<your tld>.joyent.net
  2. Using your SFTP client, view the path to your Joyent Strongspace home folder. For instance, yours might look like
     /home/data/82/users/yourname/strongspace 
  3. Create folder just below your strongspace level to which you'd like to back up files. For this example, I'll be using
     /home/data/82/users/yourname/strongspace/backup 
  4. Log out of FTP
Scripting

At this point, you'll need to write a simple script. It looks complicated, but it really isn't that tough. Here's a sample bash script, which I'll explain below:

#!/bin/bash
# Joyent Syncing Script	
rsync -azvCL --delete --progress ~/documents you@yourtld.joyent.net@strongspace.joyent.net:/home/data/82/users/yourname/strongspace/backup

(The top line should be edited so that it correctly points at wherever your shell is stored. If you use OS X, the above will work just fine.)

The rsync command looks long and complex, so let's break it into constituent parts to make it a bit more manageable.

rsync -azvCL --delete --progress

This portion calls the rsync command and tells it what options you'd like. The -azvCL is a combination of settings that I use, and that work well for me. If you'd like more info on what they mean, run 'man rsync' to see the full listing.

'–delete' tells rsync that if you delete a file on your computer, it should be deleted on Joyent as well. You can leave that out if you'd like. '–progress' gives you a nice line-by-line display of what's being uploaded and updated in the terminal. Turn it off if you'd like, but it's handy for troubleshooting.

You might want to add something like '–exclude=~/documents/music/*' if you'd like to exclude a specific folder to save space. You can add as many of these as you'd like, just add another space and another –exclude. You can use basic bash syntax here, so '–exclude=*/secret*' would exclude any file that starts with 'secret'.

 ~/documents 

This section tells rsync what folders you'd like backed up on your computer. Here, it's specifying a folder called “documents” in your home folder. Change this as you'd like.

 you@yourtld.joyent.net@strongspace.joyent.net:/home/data/82/users/yourname/strongspace/backup

This is the full address that rsync needs to use to access Joyent strongspace. Replace the 'you@yourtld.joyent.net' with your Joyent login and your joyent domain. Then, replace the '/home/data…' bit with the full path to the folder that you created earlier. Be careful not to change any of the punctuation between these elements or add any spaces, or the script will break.

Now, create a text file using the plaintext editor of your choice, and write your own version of the above script, with your specific information added in, and save the file.

Installing the script
  1. Put the script someplace safe. Either in your documents folder, or, if you're an administrator, maybe in your /bin folder so you can run it more quickly.
  2. In a terminal, type 'chmod +x /the/path/to/yourscript' This will allow you to execute the script
Running the script for the first time
  1. To run your script, open a terminal and type 'bash /the/path/to/yourscript'. If it's in your /bin folder, just type the the name of your script (e.g. 'yourscript').
  2. After possibly asking about an RSA key signature (say “Yes”), it'll ask you for your joyent account password. Type it in and hit return (it won't show up, but rest assured, it's being typed).
  3. rsync will go through the designated folders and upload everything in them to Joyent. This may take quite a while the first time it's being done.
Running the script to synchronize Joyent and your computer
  1. Run the script exactly the same as you did the first time, type in your password again.

After the initial sync, running the script will go through the folders, see what has changed, and then upload any changed files or directories to the server. Because it only needs to upload what changed, this takes a great deal less time. Unfortunately, it will have to re-upload any folders that you've moved (and their contents).

rsync is a one-way sync

One thing to keep in mind is that if you delete or change a file on the Joyent Strongspace level, either through SFTP or the Connector interface, that change will not synchronize to your computer. rsync is a one-way synchronization, and next time it syncs, it'll simply overwrite the change and make Joyent match your computer again. There's no way to make the rsync two-sided.

 
connector/using-rsync-to-sync-your-data-with-connector-strongspace.txt · Last modified: 2008/04/05 04:21 by kibitzer
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki