Agus Makmun

I'm Programmer for Python & Django. I've made quite a few web apps, especially on Django.

How to automaticly backup your projects into external hardisk in ubuntu?

07 Apr 2020 » bash, linux, ubuntu

Rsync, which stands for “remote sync”, is a remote and local file synchronization tool. It uses an algorithm that minimizes the amount of data copied by only moving the portions of files that have changed. So, you can use rsync to handle this case.

Rsync is a very flexible network-enabled syncing tool. It can also refer to the network protocol developed to utilize this tool. When we reference rsync in this guide, we are mainly referring to the utility, and not the protocol.

Due to its ubiquity on Linux and Unix-like systems and its popularity as a tool for system scripts, it is included on most Linux distributions by default.

For example:

rsync -a --exclude "*.pyc" /path/to/origin-directory/* /path/to/destination/

And then, add your command into bash file:



if [ -d $DESTINATION ]; then
    rsync -a --exclude "*.pyc" $ORIGIN $DESTINATION;
    echo "Updated at:" $(date);
    echo "Path $DESTINATION not found.";
    echo "Not updated at:" $(date);

Change mode for your bash file:

$ chmod +x

Don’t miss to add into cronjobs

$ crontab -e

then, in your editor:

# Select shell mode

# sync the folders for every hours, for more:
0 * * * * /home/yourusername/tools/ > /yourusername/tools/autosync.log 2>&1