{"id":3288,"date":"2019-06-03T19:52:59","date_gmt":"2019-06-03T11:52:59","guid":{"rendered":"https:\/\/www.ookangzheng.com\/?p=3288"},"modified":"2020-11-05T13:44:42","modified_gmt":"2020-11-05T05:44:42","slug":"using-rsync-moving-files-and-folders-between-linux","status":"publish","type":"post","link":"https:\/\/www.ookangzheng.com\/using-rsync-moving-files-and-folders-between-linux\/","title":{"rendered":"Using rsync moving files and folders between linux"},"content":{"rendered":"\n

If you want to move a folder or file from under same machine, then mv<\/code> will be enough, but if you want to move from machine A<\/code> to machine B<\/code> or different hard-drive, then rsync<\/code> will be your best friend~~.<\/p>\n\n\n\n

Using rsync move a file and remove origin files and folder<\/p>\n\n\n\n

rsync -avh --progress --remove-source-files phpMyAdmin\/* ..\/phpMyAdmin\/\n\n\/\/ You can do a second sync with --checksum to tell it to verify the results of the first synchronization<\/code><\/pre>\n\n\n\n
\/\/ Delete \u2013delete Option\ntouch test.txt\nrsync -avz --delete root@192.168.0.100:\/var\/lib\/rpm\/ .\n\n\/\/ Target has the new file called test.txt, when synchronize with the source with \u2018\u2013delete\u2018 option, it removed the file test.txt.<\/code><\/pre>\n\n\n\n
\/\/ Copy\/Sync a File on a Local Computer\n\nrsync -zvh backup.tar \/tmp\/backups\/<\/code><\/pre>\n\n\n\n
\/\/ Copy\/Sync a Directory on Local Computer\nrsync -avzh \/root\/rpmpkgs \/tmp\/backups\/<\/code><\/pre>\n\n\n\n
\/\/ Copy\/Sync a Remote Directory to a Local Machine\n\nrsync -avzh root@192.168.0.100:\/home\/tarunika\/rpmpkgs \/tmp\/myrpms<\/code><\/pre>\n\n\n\n

Rsync over ssh<\/h2>\n\n\n\n

With non standard ssh port example<\/h3>\n\n\n\n
rsync -arvz -e 'ssh -p 5543' \/etc\/caddy\/Caddyfile yourdomain.com:\/etc\/caddy\/<\/code><\/pre>\n\n\n\n

Rsync with standard port<\/h3>\n\n\n\n
rsync -avzhe ssh root@192.168.0.100:\/root\/install.log \/tmp\/<\/code><\/pre>\n\n\n\n
\/\/ Undo option, if you really need this option\n\nrsync --dry-run --remove-source-files -zvh backup.tar \/tmp\/backups\/<\/code><\/pre>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

If you want to move a folder or file from under same machine, then mv will be enough, but if…<\/p>\n","protected":false},"author":1,"featured_media":3289,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,32],"tags":[],"class_list":["post-3288","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-technology"],"_links":{"self":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts\/3288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/comments?post=3288"}],"version-history":[{"count":0,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts\/3288\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/media\/3289"}],"wp:attachment":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/media?parent=3288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/categories?post=3288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/tags?post=3288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}