Ubuntu: Backing up specific directory with it's content to remote location


I'm running Ubuntu 17.04, hosted on ovh and accessed to remotely through PuTTy (Terminal only, NO GUI).

My intention is to backup a single directory containing a running server, with all it's sub-files/directories towards a remote location where various backups would be stored (Up to a limit).

  • How often?: At least every 24h.
  • Remotely where?: Not sure, Some external service like Google Drive It may depend on how it's done. Free + More space is best.
  • Restoration processes are unnecessary, all I'd like is for that directory to be sent to a remote location where it can later be manually examined/recovered in case of any damage to the main OS or files.
  • I don't need to backup the whole system, just that directory and it's content.

What I've already checked:

  • Ubuntu's main guide for "BackupYourSystem" I still felt like I had to ask here as I'm fairly new.
  • Some of the programs listed on that guide, and other tutorials which I wasn't entirely convinced by.

Could I get some advice on how to do this? I'm one week new to ubuntu. Thanks! Any further information needed I will gladly provide.


You probably want to research rsync. Start with

man rsync  

It is a tool made for the kind of backups you want to implement.

For your use case it should be as simple as running

rsync -av --progress <user>@<host>:<directory> .  

from the machine and location where you want the backup.


To remotely use Google Drive from the command line, you can use the REST API with the curl command.

tar and zip your directory like so:

tar -jcf backup.tar.bz2 <directory>  

send it to Google Drive with

curl -d @backup.tar.bz2 https://www.googleapis.com/upload/drive/v2/files --header "Content-Type:application/x-tar"   

To do this, you need an authorization token - read about that in the documentation.

You need to modify the curl example above with the authentication.

Once this is done, and you have tested it, put it into a script. Once that is done, to run it periodically, use crontab. Check with

man crontab  

then edit your crontab entry with

crontab -e  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »