{"id":11779,"date":"2022-03-08T10:00:00","date_gmt":"2022-03-08T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11779"},"modified":"2022-03-08T14:00:04","modified_gmt":"2022-03-08T05:00:04","slug":"useful-features-of-rsync-command-in-linux","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11779","title":{"rendered":"Useful Features of Rsync Command in Linux"},"content":{"rendered":"\n<p>Today, I would like to share about usefulness of <strong>rsync<\/strong> command in Linux and how to back up data with cron job. Let\u2019s take a look.<\/p>\n\n\n\n<p>Rsync (Remote Sync) is the most commonly used command for copying and synchronizing files and directories remotely as well as locally in Linux\/Unix systems. Data can be copied, synchronized and backup both remotely and locally across directories, disks &amp; networks.<\/p>\n\n\n\n<p><strong>Advantages of Rsync Command<\/strong><\/p>\n\n\n\n<ul><li>It efficiently copies and sync files from source to destination remotely or locally.<\/li><li>It supports copying links, devices, owners, groups and permissions.<\/li><li>rsync allows to transfer just the differences between source and destination. The first time, it copies the whole content of a file or a directory from source to destination but from next time, it copies only the changed files\/data to the destination.<\/li><li>Due to using compression and decompression method while transferring data, rsync consumes less bandwidth.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Installing Rsync<\/strong><\/p>\n\n\n\n<p>rsync is preinstalled on most Linux distributions and mac-OS. If rsync hasn\u2019t been installed on the system, it can be installed easily using your distribution\u2019s package manager as follows.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>$ sudo apt-get install rsync [On Debian\/Ubuntu &amp; Mint]<\/strong><\/p>\n\n\n\n<p><strong>$ pacman -S rsync [On Arch Linux]<\/strong><\/p>\n\n\n\n<p><strong>$ emerge sys-apps\/rsync [On Gentoo]<\/strong><\/p>\n\n\n\n<p><strong>$ sudo dnf install rsync [On Fedora\/CentOS\/RHEL and Rocky Linux\/AlmaLinux]<\/strong><\/p>\n\n\n\n<p><strong>$ sudo zypper install rsync [On openSUSE]<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Rsync <\/strong><strong>Basic<\/strong><strong> Command Syntax<\/strong><\/p>\n\n\n\n<p><strong>Local to Local<\/strong><\/p>\n\n\n\n<p>rsync [OPTION] [SRC] [DEST]<\/p>\n\n\n\n<p><strong>Local to Remote<\/strong><\/p>\n\n\n\n<p>rsync [OPTION] [SRC] [USER@]HOST:DEST<\/p>\n\n\n\n<p><strong>Remote to Local<\/strong><\/p>\n\n\n\n<p>rsync [OPTION] [USER@]HOST:SRC [DEST]<\/p>\n\n\n\n<p><strong>Common options[OPTION] used with rsync commands<\/strong><\/p>\n\n\n\n<p>-v : verbose<\/p>\n\n\n\n<p>-r : copies data recursively (but don\u2019t preserve timestamps and permission while transferring data.<\/p>\n\n\n\n<p>-a : archive mode, which allows copying files recursively and it also preserves symbolic links, file permissions, user &amp; group ownerships, and timestamps.<\/p>\n\n\n\n<p>-z : compress file data.<\/p>\n\n\n\n<p>-h : human-readable, output numbers in a human-readable format.<\/p>\n\n\n\n<p>For more options, the following command can be used.<\/p>\n\n\n\n<p><strong>$ rsync -h<\/strong><\/p>\n\n\n\n<p>For example, to backup data from local to local(external hard drive), the following command is commonly used.<\/p>\n\n\n\n<p><strong>rsync -azv \/home\/username\/projects \/media\/username\/SPHardDrive\/BackupFolder<\/strong><\/p>\n\n\n\n<p><strong>Schedule backups<\/strong><\/p>\n\n\n\n<p>To enable scheduled backups, <strong>cron<\/strong> can be used for the rsync commands.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>This is all how to copy, synchronize and backup files &amp; directories. <font style=\"vertical-align: inherit\"><font style=\"vertical-align: inherit\">And I recommend <a rel=\"noreferrer noopener\" href=\"https:\/\/rsync.samba.org\/documentation.html\" target=\"_blank\">the link<\/a> to learn more about rsync.<\/font><\/font><\/p>\n\n\n\n<p>Hope you enjoy that.<\/p>\n\n\n\n<p>By Asahi<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11779\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11779\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Useful Features of Rsync Command in Linux\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11779\" data-text=\"Useful Features of Rsync Command in Linux\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11779\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11779\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Today, I would like to share about usefulness of rsync command in Linux and how to back up data with cron job. [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11779"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11779"}],"version-history":[{"count":3,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11779\/revisions"}],"predecessor-version":[{"id":11784,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11779\/revisions\/11784"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}