rsync with ReadyNAS and debian

So this post is more for me and my reproducing it when my hard drive eventually fails, on how to get the rsync setup and working with my Netgear readyNAS.

First make sure you have rsync installed, which of course you do.
Then test the commands to make sure they are working.

[codesyntax lang="bash" doclinks="0"]

[/codesyntax]

and

[codesyntax lang="bash" doclinks="0"]

[/codesyntax]

Respectfully.  Remember this is just a test, the final commands will not have the “n,v, or –progress” commands in them instead replacing it with the “q” (or quiet) option to limit the amount of chatter going to /dev/nul (you’ll see later). Also the -a option stands for archive (archive mode; equals -rlptgoD (no -H,-A,-X)

Now let’s create the bash script to be called by a cron job as root.

Being I’m using a switch and only going over my local network I’m not bothering with the overhead of doing this over ssh, because really, if you already have access to my network, your in too deep for me to stop you any more then I’ve tried. Also there are a ton of guides on using rsync over ssh, less so for just using good ol rsync by itself.

Obviously you don’t want to have these running over eachother so first do the database’s and then the htdocs directories. as I find I have much more volume in the htdocs folder then the databases.

The way bash works is you start the *.sh file with the comment #!/bin/bash and then just type in the command you want it to execute on the next line.

I’m making two files, one for each command shown above. The finished product should look something like this. My Database backups live in /var/backup/ and are being moved over to the netgear’s “backup” share in the “rsync” folder. I’ve named this file db2rsync.sh

[codesyntax lang="bash"]

[/codesyntax]

And similarly I’ve named this next file as www2rsync.sh

[codesyntax lang="bash"]

[/codesyntax]

Make these two files executable and then move them into the /root folder (or somewhere owned by root)

 

[codesyntax lang="bash"]

[/codesyntax]

and let’s move on to getting the crontab entries sorted.

As ROOT! (sudo su) type in

[codesyntax lang="bash"]

[/codesyntax]

and you’ll have a list (or not) of items in your crontab entries. The format is explained millions of places around the web so I won’t go into that. I’ll just say I want these to run around 4 in the morning, daily.

Create 2 new entries (one per line) and one for each script we are going to be calling. (a total of only 2 lines)

[codesyntax lang="bash"]

[/codesyntax]

In this example the file db2rsync.sh will be called every day at exactly 4am and will only alert me of errors, and the www2rsync.sh file will run at 4:30am, also only alerting me if there is an error.

That’s it! Save your crontab file and it should reload making those changes happen as you schedualled them! If you see

[codesyntax lang="bash"]

[/codesyntax]

then your in good shape!

Also I’d recommend running the first rsync transfer using the –progress command manually to make sure everything transfers fine and your rsync settings are working.

Hope this helps someone other then just me but even still, it’s handy to have around!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

 

  1. running Google Chrome 27.0.1453.94 Google Chrome 27.0.1453.94 on Windows 8 x64 Edition Windows 8 x64 Edition
    Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

    how do I go about using a readynas duo to automatically sync music with rsync?