{"id":1128,"date":"2013-06-17T16:46:13","date_gmt":"2013-06-17T21:46:13","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=1128"},"modified":"2013-06-17T21:17:44","modified_gmt":"2013-06-18T02:17:44","slug":"how-to-rsync-via-ssh-backup","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=1128","title":{"rendered":"HOW TO RSYNC via SSH (Backup)"},"content":{"rendered":"<header>\n<h1>HOW TO RSYNC via SSH (Backup)<\/h1>\n<p><a href=\"http:\/\/www.tanbir.net\/how-to-rsync-via-ssh-backup\/\">http:\/\/www.tanbir.net\/how-to-rsync-via-ssh-backup\/<\/a><\/p>\n<p>June 17, 2013\u00a0by Tanbir A.<\/p>\n<\/header>\n<div>\n<p><!--more--><\/p>\n<p>A very easy copy &amp; paste tutorial on how to backup your very important files from your VPS, to another VPS, or linux server.<\/p>\n<p>This shows to to make a secure connection between servers via SSH, so a password is no longer required between these two servers, and only those two servers to talk to each other.<\/p>\n<p>Make note of your servers, (this tutorial shows how to back up one VPS, to another VPS), the main server you wish to backup, and the backup server.<\/p>\n<p>Main<br \/>\nxxx.xxx.xxx.xxx<\/p>\n<p>Backup<br \/>\nxxx.xxx.xxx.xxx<\/p>\n<p>Follow the commands in\u00a0sequence\u00a0to start making backups, and changing\u00a0Blue\u00a0text to the\u00a0appropriate\u00a0user, or IP Address.<\/p>\n<p>Main&gt;\u00a0ssh-keygen -t rsa -f .ssh\/id_rsa<\/p>\n<p>-t is the encryption type<br \/>\n-f tells where to store the public\/private key pairs. In this case, the .ssh directory on home is being used<\/p>\n<p>A password will be asked; leave this part blank, just pressing &lt;enter&gt;<br \/>\nNow, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine<\/p>\n<p>Main&gt;\u00a0cd .ssh<br \/>\nMain&gt;\u00a0scp id_rsa.pub\u00a0user@Backup:~\/.ssh\/id_rsa.pub<\/p>\n<p>Of course, this time you will need to enter the password.<br \/>\nNow, login into the server machine and go to the .ssh directory on the server side<\/p>\n<p>Main&gt;\u00a0ssh\u00a0user@Backup<br \/>\nBackup&gt;\u00a0cd .ssh<\/p>\n<p>Now, add the client\u2019s public key to the know public keys on the server<\/p>\n<p>Backup&gt;\u00a0cat id_rsa.pub &gt;&gt; authorized_keys<br \/>\nBackup&gt;\u00a0chmod 644 authorized_keys<br \/>\nBackup&gt;\u00a0rm id_rsa.pub<br \/>\nBackup&gt;\u00a0exit<\/p>\n<p>Some useful Backup commands:<\/p>\n<ol>\n<li>rsync -ravz -e \u201cssh\u201d\u00a0user@Main:\/home \/root\/backup\/$(date +\u201d%d-%m-%Y\u201d)\/<\/li>\n<li>rsync -ravz -e \u201cssh\u201d\u00a0user@Main:\/etc \/root\/backup\/$(date +\u201d%d-%m-%Y\u201d)\/<\/li>\n<li>rsync -ravz -e \u201cssh\u201d\u00a0user@Main:\/var \/root\/backup\/$(date +\u201d%d-%m-%Y\u201d)\/<\/li>\n<li>rsync -ravz -e \u201cssh\u201d\u00a0user@Main:\/var\/lib\/mysql \/root\/backup\/database\/$(date +\u201d%l%p-%d-%m-%Y\u201d)\/<\/li>\n<\/ol>\n<p>To make this process\u00a0completely\u00a0automated, crate some cron jobs for these for every hour, day, week, or month, dependent on you needs of backups.<br \/>\nAs well as making another cron job to delete backup files older then 30 days, to keep backup space for daily backups!<\/p>\n<p>find \/path\/to\/files\/* -ctime +30 -exec rm -rf {} \\+<\/p>\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n<p>Full Credit to\u00a0<a href=\"http:\/\/codedpenguin.com\/\">http:\/\/codedpenguin.com<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>HOW TO RSYNC via SSH (Backup) http:\/\/www.tanbir.net\/how-to-rsync-via-ssh-backup\/ June 17, 2013\u00a0by Tanbir A.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1128"}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1128"}],"version-history":[{"count":3,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1128\/revisions"}],"predecessor-version":[{"id":1130,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1128\/revisions\/1130"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1128"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}