Using rsync to backup local files




















Assuming everything is setup correctly, you should now be logged into your remote server via SSH. Close the connection with the command. Now test the rsync functionality, and for example, to sync your Documents directory on your local PC run the command:.

Login to the remote server, and you should see a new Documents directory that is in-sync with that of your local PC. Each time you run the above command, only files that have been modified since the last time will be uploaded, so you're not constantly uploading the entire contents of the directory. Now that everything is tested and working properly, we can easily automate the entire process by adding a crontab job to our local PC.

To automatically sync your local folder to the remote server every 15 minutes, within terminal run the command. You may get a "no crontab for user" message, and you can just ignore it. Change the Documents directory to whatever you wish to backup, but ensure to leave a trailing slash for directories otherwise they will not properly backup.

If you see the crontab job that was just added, then everything is in place. Wait 15 minutes, check your remote server, and all necessary files should be there. Starting from now, all changes made to your files will be automatically uploaded to the remote server every 15 minutes. You may also use rsync to download files from the remote server and sync them to your local PC. If you ever need to sync only files that match a certain pattern, such as end with. Within terminal run the command.

Check the remote server, and you will see only files with a. Best Gaming Laptops. Best Smart Displays. Best Home Security Systems. Best External Solid State Drives.

Best Portable Chargers. Best Phone Chargers. Best Wi-Fi Range Extenders. Best Oculus Quest 2 Accessories. Best iPad Air Cases. Awesome PC Accessories.

Best Linux Laptops. Best Wireless iPhone Earbuds. Best Bluetooth Trackers. Best eReaders. Best VPN. Browse All News Articles. Windows 11 Uninstall Clock. Teams Walkie-Talkie. PCI Express 6.

Wordle Scams. T-Mobile iCloud Private Relay. Avira Antivirus Crypto Miner. Linux PinePhone Pro. Google Green Messages. Use Your iPhone as a Webcam. Hide Private Photos on iPhone. All Microsoft's PowerToys for Windows. Take Screenshot by Tapping Back of iPhone. Windows 11 Default Browser. Browse All Windows Articles. Windows 10 Annual Updates. OneDrive Windows 7 and 8.

Copy and Paste Between Android and Windows. Protect Windows 10 From Internet Explorer. Both of these directories are on the same hard drive, but this would work exactly the same if the directories existed on two different drives. There are several different ways we can approach this, depending on what kind of backups you want to configure.

For most purposes, the following line of code will suffice:. The code above will synchronize the contents of Directory1 to Directory2, and leave no differences between the two. If rsync finds that Directory2 has a file that Directory1 does not, it will delete it. If rsync finds a file that has been changed, created, or deleted in Directory1, it will reflect those same changes to Directory2. There are a lot of different switches that you can use for rsync to personalize it to your specific needs.

Here is what the aforementioned code tells rsync to do with the backups:. The reason I think verbose is important is so you can see exactly what rsync is backing up. Think about this: What if your hard drive is going bad, and starts deleting files without your knowledge, then you run your rsync script and it pushes those changes to your backups, thereby deleting all instances of a file that you did not want to get rid of?

If you choose to use this option, I recommend also using the verbose options, for reasons mentioned above. The screenshot above tells us that File1. Noob tip: Notice the trailing slashes at the end of the directories in my rsync command — those are necessary, be sure to remember them.

That about covers it as far as local backups are concerned. As you can tell, rsync is very easy to use. It gets slightly more complex when using it to sync data with an external host over the Internet, but we will show you a simple, fast, and secure way to do that. Most servers and even many clients already have SSH, and it can be used for your rsync backups.

We will show you the process to get one Linux machine to backup to another on a local network. On the server the computer that will be receiving the backups , make sure SSH and rsync are installed.



0コメント

  • 1000 / 1000