Creating automatic backup in Solus
10 Oct 2016This morning I accidentally (well, I was not aware that I was not in the correct folder) all my project files today.
Lesson learned - recovery for (rm -rf *) is almost impossible.
The good thing is that I worked on the project over the weekend, so some stuff are still fresh in my mind. But first, I am going to create back up and automate it for every 2 hours because I am paranoid like that. I am going to leave the backup on my desktop.
In Solus, cron is not installed by default and they use systemd/Timers (https://wiki.archlinux.org/index.php/Systemd/Timers) instead for replacement.
Create a file named as backup-workspace.service in /etc/systemd/system
<pre>cd /etc/systemd/system
sudo touch backup-workspace.service
</pre>Add in the following using your favorite text editor:
<pre># Systemd
# Service (/etc/systemd/system/backup-workspace.service)
[Unit]
Description=automatically backup workspace
[Service]
ExecStart=tar -cvpzf /home/raf/Desktop/Workspace-backup.tar.gz /home/raf/Workspace
# Timer (/etc/systemd/system/backup-workspace.timer)
[Unit]
Description=Runs backup-workspace service every hour
[Timer]
# Time to wait after booting before we run first time
OnBootSec=1min
# Time between running each consecutive time
OnUnitActiveSec=1h
Unit=backup-workspace.service
[Install]
WantedBy=multi-user.target
I created an alias/shortcut key to do the backup manually too by editing my ~/.bashrc file.
<pre>alias backup=”tar -cvpzf /home/raf/Desktop/Workspace-backup.tar.gz /home/raf/Workspace”</pre><pre></pre></pre>