How to regularly clone a folder in Ubuntu.

Photo by Kevin Horvat on Unsplash

After looking for backup solutions, I came to the conclusion that it can be quite easy to regularly clone a folder in Ubuntu. This is way the files are not compressed or altered in any way. It can be quite useful if you are running VMs and you need to have backups of them, but you also need the backups to be easily accessible if necessary.

This works regardless of the Ubuntu version you are running.

Depending on your permissions, you simply have to add a line in crontab. In my case, I had to “sudo” it.

Yet again, depending on your configuration:

crontab -e

or

sudo crontab -e

Then copy this line at the end

00 01 * * 6 sudo rsync -avu /SOURCE_FOLDER /DESTINATION_FOLDER

Here is a breakdown of what everything means:

00 01 * * 6

This is when the line should run. In my case, at 00 minutes, at 01 hours, each Saturday (night).

Here you can edit your own cron schedule expressions (https://crontab.guru/)

(sudo) rsync -avu

  • a — archive files and directory while synchronizing
  • v — verbose output
  • u — do not copy the files from source to destination if destination files are newer

To check whether the scheduler is properly entered or not, simply do a:

crontab -l

or

sudo crontab -l

You should see the line you added at the end of the output.

 by the author.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to use MongoDB with Graphical IDEs

Easy Image recognition for automation with python

Resources I used to pass the AWS Solutions Architect — Associate Certification Exam

Checking how fast your method in ruby using Benchmark module

SALOME-MECA: Software hangs up on applying thickness command

Java Lambda Expressions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrei Barburas

Andrei Barburas

More from Medium

The easy way to run the vlang code in gvim.

Git Cheatsheet Every Dev. MUST know

Which is Better for Web Development: PHP or Python?

How to shut down a computer using Python — ProgSkillss