summaryrefslogtreecommitdiff
path: root/src/Backing_up_a_Server_Remotely_Using_Minimal_Bandwidth.adoc
blob: 1b1e944a6a55a8d0e559cfc644903c55d64dd20b (plain)
    1 Backing up a Server Remotely Using Minimal Bandwidth 
    2 ====================================================
    3 :author: Aaron Ball
    4 :email: nullspoon@iohq.net
    5 
    6 The server that runs this website (and a lot of others) also runs a lot of
    7 other services such as an IRC server, a Jabber server, NGINX (of course), and
    8 various other things. I like to take a lot of backups, especially since I'm not
    9 the best person in the area of security. With that, my old way of backing my my
   10 server was relatively painful. I had a script that tarred and compressed each
   11 service directory individually and move it to a secure location on my web
   12 server for download. After download, the script would remove the backup, and
   13 continue to the next.
   14 
   15 The problem with this method is that it consumes a lot of bandwidth and time.
   16 By the time I have downloaded everything, I have used up several gigabytes of
   17 bandwidth. I don't mind so much about the bandwidth though.  What's important
   18 is the time and interraction it takes.
   19 
   20 
   21 [[enter-the-light-bulb...]]
   22 == Enter the Light Bulb...
   23 
   24 I've been using rsync for some time now to mirror my laptop to my server
   25 at home. For some reason, it never occurred to me to use rsync with a
   26 private key to log in to my server and download the deltas to my local
   27 machine. If I want a single compressed tar file for a backup, all I have
   28 to do is backup my local server's copy of everything rather than doing
   29 it on my web server and downloading that. Ending this already too long
   30 blog post on this simple topic, here's the rsync command I'm using...
   31 
   32 ----
   33 sync -avP --delete --chmod=g+rx --rsh="ssh -p1234 -i ~/.ssh/id_rsa.pdeb.user" user@server.net:/dir1 /home/server/dir1
   34 ----
   35 
   36 
   37 [[a-quick-explanation]]
   38 == A Quick Explanation
   39 
   40 * *rsync -avP* uses default rsync settings (-a), specifies verbose mode
   41 (-v) and sets rsync to display its progress on each individual file as it goes
   42 (-P).
   43 
   44 * *--delete* option, rsync will delete files on the destination if they
   45 deleted on the source (this isn't default).
   46 
   47 * *--chmod=g+rx* sets the group settings on the destination to group
   48 with read and write. This is handy if you want to access the backups from
   49 another account that doesn't have access on the server too. This switch is not
   50 necessary.
   51 
   52 * *--rsh="ssh -p1234 -i ~/.ssh/id_rsa.user"* specifies a custom port to
   53 connect on (port 1234 in this case) and specifies a private key to use when
   54 attempting to log in.
   55 
   56 * *user@server.net:dir1 /home/server/dir1* is the host (server) to
   57 connect to along with the user to try (user), the source directory (:/dir) and
   58 the destination directory (/home/server/dir1).
   59 
   60 
   61 Category:Linux
   62 Category:Backups
   63 Category:SSH
   64 
   65 
   66 // vim: set syntax=asciidoc:

Generated by cgit