{"id":1389,"date":"2023-04-27T07:03:14","date_gmt":"2023-04-27T06:03:14","guid":{"rendered":"https:\/\/editjournal.redakt.eu\/faxmodem\/?p=1389"},"modified":"2023-04-27T07:27:54","modified_gmt":"2023-04-27T06:27:54","slug":"migrate-vps-to-another-server-rsync","status":"publish","type":"post","link":"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/servers\/migrate-vps-to-another-server-rsync\/","title":{"rendered":"Migrate whole VPS to another server using rsync"},"content":{"rendered":"<p>Say you're about to cancel a VPS, but first you need to copy its contents (<em>source<\/em>) over to another server (<em>destination<\/em>).<\/p>\n<p>We will be using <code>rsync<\/code>. Note: rsync will keep the original timestamps for both files and folders, so that's good.<\/p>\n<p>General idea:<\/p>\n<pre><code>rsync --params source destination<\/code><\/pre>\n<p>Because we will copy the whole <em>source<\/em> VPS, we will have to do it using the <code>root<\/code> account to avoid permission errors. Since most likely you won't be able to SSH into your <em>source<\/em> with root from any other server, instead you will have to <code>su<\/code> to root on the <em>source<\/em>, and then SSH into the <em>destination<\/em>. Could be any account on the <em>destination<\/em>, but lets say it's <code>admin<\/code>.<\/p>\n<p>Updated general idea:<\/p>\n<pre><code>rsync --params \/ admin@example.com:\/folder<\/code><\/pre>\n<p>Start by configuring SSH access from the <em>source<\/em> server to the <em>destination<\/em> server.<\/p>\n<ol>\n<li>Elevate to <code>root<\/code> on the source server: <code>su -<\/code> or <code>sudo su -<\/code><\/li>\n<li>Display and copy the public key of the root account: <code>cat ~\/.ssh\/id_rsa.pub<\/code><\/li>\n<li>Go to the destination server. Log in to the <code>admin<\/code> account. Open it's <code>~\/.ssh\/authorized_keys<\/code> for editing and put the copied key in there.<\/li>\n<li>Test the connection on the <em>source<\/em> server: <code>ssh admin@example.com -p 2222<\/code><\/li>\n<\/ol>\n<p>Copying from this server to another<\/p>\n<pre><code>rsync -aAXvh --exclude={&quot;\/dev\/*&quot;,&quot;\/proc\/*&quot;,&quot;\/sys\/*&quot;,&quot;\/tmp\/*&quot;,&quot;\/run\/*&quot;,&quot;\/mnt\/*&quot;,&quot;\/media\/*&quot;,&quot;\/lost+found&quot;,&quot;\/usr\/*&quot;,&quot;\/lib\/*&quot;,&quot;\/opt\/*&quot;,&quot;\/var\/cache\/*&quot;,&quot;\/var\/lib\/*&quot;} -e &#039;ssh -p 2222&#039; \/ admin@example.com:~\/backup-folder<\/code><\/pre>\n<p>Notes:<\/p>\n<ul>\n<li><code>&#039;ssh -p 2222&#039;<\/code>: use this specific port for SSH connection<\/li>\n<li><code>~\/backup-folder<\/code>: the copy will go to the <code>backup-folder<\/code> directory inside user's home directory (<code>~<\/code>)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Say you&#8217;re about to cancel a VPS, but first you need to copy its contents (source) over to another server (destination). We will be using rsync. Note: rsync will keep the original timestamps for both files and folders, so that&#8217;s good. General idea: rsync &#8211;params source destination Because we will copy the whole source VPS,&hellip; <a class=\"more-link\" href=\"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/servers\/migrate-vps-to-another-server-rsync\/\">Continue reading <span class=\"screen-reader-text\">Migrate whole VPS to another server using rsync<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[956],"tags":[775,1078,817],"class_list":["post-1389","post","type-post","status-publish","format-standard","hentry","category-servers","tag-debian","tag-rsync","tag-vps","entry"],"_links":{"self":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/comments?post=1389"}],"version-history":[{"count":3,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1389\/revisions"}],"predecessor-version":[{"id":1395,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1389\/revisions\/1395"}],"wp:attachment":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/media?parent=1389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/categories?post=1389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/tags?post=1389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}