Optimizing your experience
Gradient background

Setting up my environment in Fedora - Creating backups

Clarice Bouwer

Software Engineering Team Lead and Director of Cloudsure

Saturday, 20 October 2018 · Estimated 2 minute read

I had to re-install so I documented my process. In this post, I focus on getting my data backed up so that I can restore it after the installation.

Whatever isn't in git gets archived. This is mainly my home directory. I want it backed up to my VM at CloudAfrica and to my external HDD. If I have learned anything in this process it is that my SSH keys are the most vital piece of bits that I own and that I need one copy in a safe location. Whatever safe means in this world.


tar cpzvf <archive>.tar.gz /home/<username>
  • -c, --create
  • -p, --preserve-permissions, --same-permissions
  • -z, --gzip, --gunzip, --ungzip
  • -v, --verbose
  • -f, --file=ARCHIVE

Copy to server

rsync -avzh <username>@<host>:/path/to/copy/to/<archive>.tar.gz /path/to/copy/from/<archive>.tar.gz
  • -a, --archive
  • -v, --verbose
  • -z, --compress
  • -h, --human-readable

I had a few permissions hiccups trying to tar my home directory so I took extra steps to tackle these problems.

Remote Git Repository

I use my own remote git repository for directories that contain sensitive information. I followed these instructions to get set up.

Create a git user and allow ssh access to authorized users. On the local machine copy the public key cat ~/.ssh/id_rsa.pub (or whichever public key you use) and paste it into .ssh/authorized_keys after it has been created.

ssh <username>@<host>
sudo adduser git
su git
mkdir /.ssh && chmod 700 /.ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys

Create the .git project and initialize it.

cd /srv/git
mkdir project.git
cd project.git
git init --bare

Configure the git repo locally and point to the newly created remote repository.

cd /home/<user>/path/to/project
git init
git add .
git commit -m "Initial commit"
git remote add origin git@<host>:/srv/git/project.git
git push origin master

_If you have problems pushing, check that the directory permissions are not assigned to root ls -lah. Assign the files and folders to git using sudo chown git _*

Global save-to-git script

Let's take a practical example: I want to store my Gnote notes to my remote repository.

  1. Create a bash script save-gnote and add it to git. Make it add all unstaged files in the gnote directory and commit them using a timestamp in the commit message then push to origin.

cd /home/<user>/.local/share/gnote
git add .
git commit -m "Backup $(date +%s)"
git push origin master
  1. Give the script execution rights chmod a+x save-gnote.
  2. Create a symlink to access the script from anywhere.
ln -s /home/<user>/.local/share/gnote/save-gnote /usr/local/bin/save-gnote
  1. Access save-gnote from any directory in the terminal.