{"id":3944,"date":"2023-11-24T15:06:24","date_gmt":"2023-11-24T07:06:24","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3944"},"modified":"2026-03-13T15:03:42","modified_gmt":"2026-03-13T07:03:42","slug":"backup-linux-server-using-rclone","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/backup-linux-server-using-rclone","title":{"rendered":"7 Easy Steps to Backup Linux Server to Object Storage Using Rclone"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3945\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-300x169.jpeg\" alt=\"using Rclone\" width=\"705\" height=\"397\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/50-390x219.jpeg 390w\" sizes=\"(max-width: 705px) 100vw, 705px\" \/><\/p>\n<div class=\"markdown markdown-main-panel\" dir=\"ltr\">\n<p data-sourcepos=\"5:1-5:127\">In this comprehensive guide, we will delve into the process of creating both manual and scheduled backups of any Linux server to Object Storage using rclone. This guide caters to a wide range of Linux servers, including Dedicated Servers, VPS, and VDS. The provided commands have been thoroughly tested with Ubuntu 18.04(64 Bit), Ubuntu 20.04(64 Bit), Debian 9, and Debian 10. While these commands are primarily tailored for these distributions, slight adjustments may be required for other distributions like CentOS.<\/p>\n<p data-sourcepos=\"7:1-7:140\">Throughout this guide, it is assumed that you have root access to the Linux server. To elevate your privileges, enter the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo -i\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"13:1-13:45\"><strong>Initial Linux Server Backup Configuration<\/strong><\/h2>\n<ol data-sourcepos=\"15:1-16:0\">\n<li data-sourcepos=\"15:1-16:0\"><strong>Acquiring Object Storage Credentials for Backup Storage<\/strong><\/li>\n<\/ol>\n<p data-sourcepos=\"17:1-17:77\">In this tutorial, we will utilize Object Storage as our backup destination. We assume that you already have an active Object Storage subscription.<\/p>\n<p data-sourcepos=\"19:1-19:219\">To proceed, you will need to gather the necessary credentials, including the access_key, secret_key, and URL. These credentials can be obtained from the Object Storage section of your server&#8217;s Control Panel (CCP).<\/p>\n<ol start=\"2\" data-sourcepos=\"21:1-22:0\">\n<li data-sourcepos=\"21:1-22:0\"><strong>Creating a Backup File on the Linux Server<\/strong><\/li>\n<\/ol>\n<p data-sourcepos=\"23:1-23:119\">Before proceeding with the backup process, we need to install the latest version of rclone using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">curl https:\/\/rclone.org\/install.sh | sudo bash\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"29:1-29:175\">Next, we will create a backup of the current user and store the backup file with the current date in the \/opt\/backup\/ directory. Execute the following command to achieve this:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\"><span class=\"citation-0 citation-end-0 animating\">mkdir \/opt\/backup\/ cd \/opt\/backup &amp;&amp; tar -cvzf backup-$(date +%d.%m.%Y).tar.gz --directory=\/ --exclude=lost+found --exclude=dev\/* --exclude=proc\/* --exclude=run\/* --exclude=sys\/* --exclude=tmp\/* --exclude=mnt\/* --exclude=media\/* --exclude=opt\/backup\/*<\/span><span class=\"animating\"> .<\/span><\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"37:1-37:34\">Here&#8217;s a breakdown of the command:<\/p>\n<ul data-sourcepos=\"38:1-49:0\">\n<li data-sourcepos=\"38:1-39:0\">\n<p data-sourcepos=\"38:3-38:68\"><code class=\"\">tar<\/code>: The <code class=\"\">tar<\/code> command is used to create an archive of our data.<\/p>\n<\/li>\n<li data-sourcepos=\"40:1-41:0\">\n<p data-sourcepos=\"40:3-40:88\"><code class=\"\">c<\/code>: This option stands for <code class=\"\">create<\/code> and indicates that we are creating a new archive.<\/p>\n<\/li>\n<li data-sourcepos=\"42:1-43:0\">\n<p data-sourcepos=\"42:3-42:88\"><code class=\"\">v<\/code>: This option represents <code class=\"\">verbose<\/code> and provides detailed output during the process.<\/p>\n<\/li>\n<li data-sourcepos=\"44:1-45:0\">\n<p data-sourcepos=\"44:3-44:93\"><code class=\"\">z<\/code>: This option signifies <code class=\"\">gzip<\/code>, implying that the archive will be compressed using gzip.<\/p>\n<\/li>\n<li data-sourcepos=\"46:1-47:0\">\n<p data-sourcepos=\"46:3-46:178\"><code class=\"\">f<\/code>: This option represents <code class=\"\">file<\/code> and specifies the name and location of the archive. It must be the last option passed, as everything following <code class=\"\">f<\/code> is treated as a file path.<\/p>\n<\/li>\n<li data-sourcepos=\"48:1-49:0\">\n<p data-sourcepos=\"48:3-48:84\"><code class=\"\">\/path\/filename.tar.gz<\/code>: This indicates the path where the archive will be stored.<\/p>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"50:1-50:179\">In this command, certain directories have been excluded from the backup process due to storage space considerations or the presence of unwanted large files in the <code class=\"\">tmp<\/code> directory.<\/p>\n<ol start=\"3\" data-sourcepos=\"52:1-53:0\">\n<li data-sourcepos=\"52:1-53:0\"><strong>Configuring Rclone on a Linux Server<\/strong><\/li>\n<\/ol>\n<p data-sourcepos=\"54:1-54:117\">For this step, we assume that the files and folders you intend to back up are stored in the <code class=\"\">\/opt\/backup\/<\/code> directory.<\/p>\n<p data-sourcepos=\"56:1-56:179\">If you haven&#8217;t already, follow the instructions in our product documentation to set up Rclone. Once Rclone is configured, we can proceed with the Linux server backup using Rclone.<\/p>\n<ol start=\"4\" data-sourcepos=\"58:1-59:0\">\n<li data-sourcepos=\"58:1-59:0\"><strong>Transferring Your Backup File from Linux Server to Object Storage<\/strong><\/li>\n<\/ol>\n<p data-sourcepos=\"60:1-60:255\">In this step, we will transfer the backup file created in step 2 to the Object Storage. Assuming you have named your object store <code class=\"\">eu2<\/code> and your backup folder <code class=\"\">backup<\/code>, execute the following command to create a bucket where we will store all the files:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">rclone mkdir eu2:backup\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"61:1-61:40\">After completing the steps in the &#8220;Initial Configuration&#8221; section, run the following command to save the files to your Object Storage:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">rclone copy -P \/opt\/backup eu2:backup\/server1\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"72:1-72:79\">This command will transfer all data from <code class=\"\">\/opt\/backup<\/code> to the specified bucket.<\/p>\n<p data-sourcepos=\"74:1-74:53\">Here are the available options for transferring data:<\/p>\n<ul data-sourcepos=\"76:1-81:0\">\n<li data-sourcepos=\"76:1-77:0\">\n<p data-sourcepos=\"76:3-76:118\"><code class=\"\">rclone copy -P \/opt\/backup eu2:bucketname\/server1<\/code>: This command copies all data without deleting the source files.<\/p>\n<\/li>\n<li data-sourcepos=\"78:1-79:0\">\n<p data-sourcepos=\"78:3-78:141\"><code class=\"\">rclone move -P \/opt\/backup eu2:bucketname\/server1<\/code>: This command moves all data, deleting the source files after the transfer is complete.<\/p>\n<\/li>\n<li data-sourcepos=\"80:1-81:0\">\n<p data-sourcepos=\"80:3-80:161\"><code class=\"\">rclone sync -P \/opt\/backup eu2:bucketname\/server1<\/code>: This command synchronizes the data, ensuring that the files on the server and in the bucket are identical.<\/p>\n<\/li>\n<\/ul>\n<ol start=\"5\" data-sourcepos=\"82:1-83:0\">\n<li data-sourcepos=\"82:1-83:0\">\n<div class=\"markdown markdown-main-panel\" dir=\"ltr\">\n<p data-sourcepos=\"1:1-1:152\"><strong>Scheduling Rclone Backups<\/strong><\/p>\n<p data-sourcepos=\"5:1-5:121\">After completing the initial configuration steps, you can set up scheduled backups to run automatically. To achieve this, follow these steps:<\/p>\n<ul data-sourcepos=\"7:1-10:7\">\n<li data-sourcepos=\"7:1-10:7\">\n<p data-sourcepos=\"7:4-8:63\">Create a script file: Start by creating a script file using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">sudo nano \/var\/rclone.sh\r\n<\/code><\/pre>\n<\/div>\n<\/li>\n<li data-sourcepos=\"13:1-14:54\">\n<p data-sourcepos=\"13:4-14:54\">Add the script contents: Open the script file in the nano editor and add the following contents:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\"><span class=\"hljs-meta\">#!\/bin\/bash<\/span>\r\n\r\n<span class=\"hljs-comment\"># Navigate to the backup directory<\/span>\r\n<span class=\"hljs-built_in\">cd<\/span> \/opt\/backup\r\n\r\n<span class=\"hljs-comment\"># Create a backup archive with the current date<\/span>\r\n<span class=\"citation-0 citation-end-0\">tar -cvzf backup-$(date +%d.%m.%Y).tar.gz --directory=\/ --exclude=lost+found --exclude=dev\/* --exclude=proc\/* --exclude=run\/* --exclude=sys\/* --exclude=tmp\/* --exclude=mnt\/* --exclude=media\/* --exclude=opt\/backup\/*<\/span> .\r\n\r\n<span class=\"hljs-comment\"># Sync the backup files to the S3 storage<\/span>\r\n\/usr\/bin\/rclone sync -P --update --verbose --transfers 30 --log-file=\/var\/<span class=\"hljs-built_in\">log<\/span>\/upload.log <span class=\"hljs-string\">\"\/opt\/backup\"<\/span> <span class=\"hljs-string\">\"eu2:backup\/\"<\/span><\/code><\/pre>\n<\/div>\n<\/li>\n<li data-sourcepos=\"29:1-34:0\">\n<p data-sourcepos=\"29:4-30:67\">Make the script executable: To ensure the script can be executed, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">sudo chmod +x \/var\/rclone.sh\r\n<\/code><\/pre>\n<\/div>\n<\/li>\n<li data-sourcepos=\"35:1-40:0\">\n<p data-sourcepos=\"35:4-36:103\">Add the script to cron: To schedule the script to run at a specific time, open the crontab file using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">sudo crontab -e\r\n<\/code><\/pre>\n<\/div>\n<\/li>\n<li data-sourcepos=\"41:1-46:0\">\n<p data-sourcepos=\"41:4-42:110\">Add the cron job: At the end of the crontab file, add the following line to schedule the backup script to run daily at 02:00:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">0 2 * * * \/var\/rclone.sh\r\n<\/code><\/pre>\n<\/div>\n<\/li>\n<li data-sourcepos=\"47:1-49:0\">\n<p data-sourcepos=\"47:4-48:35\">Save the crontab file: Save and close the crontab file.<\/p>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"50:1-50:192\">With these steps completed, the script will now run automatically every day at 02:00, creating a backup archive and transferring it to the Object Storage. You can modify the cron job to run at a different time or frequency as per your requirements.<\/p>\n<h2 data-sourcepos=\"52:1-52:26\"><strong>Additional Information<\/strong><\/h2>\n<ul data-sourcepos=\"54:1-57:0\">\n<li data-sourcepos=\"54:1-55:0\">\n<p data-sourcepos=\"54:3-54:218\">For more detailed information on rclone flags and configuration options, refer to the <a href=\"https:\/\/rclone.org\/docs\/\" rel=\"nofollow noopener\" target=\"_blank\">official documentation.<\/a><\/p>\n<\/li>\n<li data-sourcepos=\"56:1-57:0\">\n<p data-sourcepos=\"56:3-56:112\">In some cases, if your upload speed is slow, you may need to add the <code class=\"\">-s3-chunk-size 200M<\/code> flag to the script.<\/p>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"58:1-58:304\">By following these comprehensive instructions, you can effectively back up your Linux servers using rclone and Object Storage, ensuring the safety and security of your valuable data. Remember to regularly review and update your backup strategy to adapt to changing data needs and storage requirements.<\/p>\n<h2 data-sourcepos=\"5:1-5:2\"><strong>Conclusion<\/strong><\/h2>\n<p data-sourcepos=\"7:1-7:174\">By following the detailed instructions provided in this comprehensive guide, you can effectively implement a robust backup strategy for your Linux servers using rclone and Object Storage. This guide covers the entire process, from initial configuration to scheduling automated backups, ensuring that your valuable data remains safe and secure. Remember to regularly review and update your backup strategy to adapt to evolving data needs and storage requirements.<\/p>\n<\/div>\n<p data-sourcepos=\"7:1-7:174\">\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this comprehensive guide, we will delve into the process of creating both manual and scheduled backups of any Linux server to Object Storage using rclone. This guide caters to a wide range of Linux servers, including Dedicated Servers, VPS, and VDS. The provided commands have been thoroughly tested with Ubuntu 18.04(64 Bit), Ubuntu 20.04(64 Bit), Debian 9, and Debian&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1115],"class_list":["post-3944","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-rclone"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3944"}],"version-history":[{"count":6,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3944\/revisions"}],"predecessor-version":[{"id":6256,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3944\/revisions\/6256"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3944"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3944"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}