Skip to content

Python application for backing up and synchronizing data

License

Notifications You must be signed in to change notification settings

wojtazk/py-backapp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Backup App

Backup and synchronize your data with Py-BackApp

Requirements

Note

Project was tested on python 3.12.7

Project uses only built-in python libraries, so the only requirement is Python

Cloning repo

git clone https://github.com/Atomowyy/py-backapp && cd py-backapp

Running Client

Note

Change directory to client

Interactive mode

Run with no arguments or with -i flag to start interactive mode

python backapp.py
python backapp.py -i

image

CLI mode

python backapp.py -h
usage: backapp.py [-h] [-i] [--username USERNAME] [--server SERVER] [--port PORT] [-g] [-v] [--local LOCAL]
                  [--remote REMOTE] [-l] [-r] [-R] [-u] [-d] [-s] [-S]

This is the client side of py-backapp, backup and synchronize your files with the server.If no argument is
specified the program starts in interactive mode

options:
  -h, --help           show this help message and exit
  -i, --interactive    start py-backapp in interactive mode
  --username USERNAME  set username in config.json
  --server SERVER      set server in config.json
  --port PORT          set port in config.json
  -g, --gettoken       authorize user on the server and get a token
  -v, --verifytoken    verify if current token is valid
  --local LOCAL        path to local resource
  --remote REMOTE      path to remote resource
  -l, --list           list contents of remote dir
  -r, --remove         remove remote resources
  -R, --removeall      remove all users' remote resources
  -u, --upload         upload local resources to the server
  -d, --download       download remote resources from the server
  -s, --syncfile       compare local and remote file and get the newer one
  -S, --syncdir        synchronize local directory with the remote one

source code: https://github.com/Atomowyy/py-backapp

image image image

Running Server

Note

Change directory to server

python server.py

image

Adding users to servers' database

Note

Change directory to server

Users are stored in users_db.json

python users_db_add_user.py

image image

Self-signed SSL certificate with openssl

Generate a 2048-bit RSA private key:

openssl genrsa -out ./server/certificates/py-backapp-server.key 2048

Generate a certificate signing request:

openssl req -new -key ./server/certificates/py-backapp-server.key -out ./certificates/py-backapp-server.csr

Generate self-signed certificate, valid for 365 days:

openssl x509 -req -days 365 -in ./server/certificates/py-backapp-server.csr -signkey ./certificates/py-backapp-server.key -out ./certificates/py-backapp-server.crt

Verify certificate and key:

openssl x509 -in ./server/certificates/py-backapp-server.crt -noout -text
openssl rsa -in ./server/certificates/py-backapp-server.key -noout -text



Modify ceritficates in server.py or set the env variables

# FIXME: use your certificates, default certificates are for development purposes only and shouldn't be used
CERTFILE = os.getenv('CERTFILE', 'certificates/py-backapp-server.crt')
KEYFILE = os.getenv('KEYFILE', 'certificates/py-backapp-server.key')
export CERTFILE=certificates/py-backapp-server.crt
export KEYFILE=certificates/py-backapp-server.key

Docker

Building server image

docker image build -f ./server/server.Dockerfile -t py-backapp:test .

Running server in a container

docker container run -p 1234:1234 py-backapp:test

Running bash in a server container

docker container run -it -p 1234:1234 py-backapp:test /bin/bash

Running server with docker-compose

docker-compose -f docker-compose.yml up



image image

About

Python application for backing up and synchronizing data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.3%
  • Dockerfile 0.7%