...

backup tool

Backup remote server content via SSH/SCP using automated tool


Repositories


 

How does it work?


Firstly tool is opening connection to remote server via SSH. After successful login it is possible to execute remote commands like via SSH. In below example I am creating Postgres DB dump which later will be downloaded (lines 3, 6, 10)

In line 13, FileManager is collecting backup locations and skip paths stored in YAML file (e.g. backup_source.yaml seen below). Skip locations might be useful when you want avoid downloading large numbers of small files like Python virtual environments, system files etc.

Method call in line 16 is responsible for downloading paths provided in configuration file with respective avoiding paths which  you don't want to download.

Finally call in line 19 is storing downloaded files into tar archive.

 

CI used in this tool


This is first bigger project where I am using CI provided by GitHub (GitHub workflows).

In this particular case action is called on every push. Trigger creates Docker image with Ubuntu - latest LTS. Ubuntu container will run the tests and host Alpine Docker image as well (SSH server mocker used for tests).

Line 14 uses shell script to generate private key which will be copied to the SSH server mocker. Line 15 gives owner 'rw-------' rights.

Line 21 is using docker-compose to build & run in background (-d option) SSH mocker based on Alpine image with few modifications described in docker-compose.yaml.

Line 24 and 27 aproprietly:

- Install all necessary packages stored in requirements.txt

- Run all test from selected file test_functional.py using PyTest.