Saturday, September 3, 2016

How to Set Up an Ultimate Backup System, Using Duplicity, Systemd and Thunar on Arch Linux Part Three



How to Setup Automated Duplicity Backups for the User: 

Now that we have set the automated backups for the system, it is time to do the same for the user. The process is similar with some minor modifications. First things first, we need an operation folder where we will place all of the duplicity related files. Create the following folder:
mkdir /home/my_user/.config/duplicity_backup
In order to simplify our life when we are implementing the front end, we will not place all of the duplicity parameters into one file. Create the following file:
vim /home/my_user/.config/duplicity_backup/exclude_list.txt 
This file will contain the list of files and folders that should be excluded from backup. It should be filled in similar to this:


Note that Music, Videos and Pictures are excluded in this case, this is done to conserve space on the remote server. Fill free to include those folders, by removing them from the list.  Now we need to specify the remote repository where the files will be stored:
cd /home/my_user/.config/duplicity_backup/ 
echo "scp://my_user@server///home/my_user/repos/me" > repo_location
 Finally we need to create the backup scripts:
vim back_home_up.sh
with the following content:

Make this script executable and run it:
chmod +x back_home_up.sh
back_home_up.sh
Now you should have your first full backup of home folder on the remote repository. It is time to set up user units for systemd to automate it. Navigate to the ~/.config/systemd/user folder, if it is not there create it. Than create duplicity-remote-backup.service and duplicity-remote-backup.timer
files with the following content:


Now enable the timer by executing:
systemctl --user enable duplicity-remote-backup.timer
This shall conclude the back-end of the duplicity backup system for the user. Next we will discuss the front-end.


How to Implement a Front-end to Duplicity for Thunar, Using thunarx-python:

Thunarx-python provides python bindings for the Thunar Extension Framework. We will be using it to implement a Thunar plugin that provides a submeny with restore options. To install it on Arch Linux you either need to download it from AUR and install it manually or run the following command: 
yaourt thunarx-python
Once the installation is complete, create the following file:
sudo vim /usr/share/thunarx-python/extensions/thunarx-submenu-plugin.py 
with this content: 

Don't forget to edit line 12 and set the dup_folder to the correct location. This will add the submenu option "Restore"  to Thunar when you right click on a file. For this to work you need to add one more additional file to   /usr/local/lib/python2.7 . Execute the following commands in command line:
cd /usr/local/lib/python2.7 
sudo vim dupController.py
and fill it in with:

Now you should have it all up and running, test it by restoring and arbitrary file.





No comments:

Post a Comment