Skip to main content

Backup a usb key to another usb key with the same space disk

Project description

backupmystemusb2usb is a GPLv3-liscensed Python package for copy usb key.

Its runs on Python 3.7 and has a dependency for yaml, and another one for the gui.

Installation without the source

To install backupmystemusb2usb package run the following command:

sudo apt-get install libyaml-dev python3-gi
sudo -H pip3 install backupmystemusb2usb

You have to create a config.yml file (you can saved it into your ~/.local/share/backupmysystemusb2usb directory)

UUID_1_Master: 790d1fbb-96ed-46c3-868d-08e05e223fa7
UUID_1_Slave: 790d1fbb-96ed-46c3-868d-08e05e223fa7
Temp_img: /home/stephane/Temp/Linux.img
Temp_log: /home/stephane/Temp/BackupMySystem-Temp.log
Kill_dd: True

UUID list

sudo blkid

Find your device and for change the label. If the device master UUID is the same as the slave UUID (if you cancel in copy img to slave), you have to put a date upper on master than slave

Warning UUID is not Label !

sudo e2label /dev/sd_1 "19991231235959"

For the deamon, write a run.py for running by user root with chmod 700

#!/usr/bin/env python3
import sys
import yaml
from backupmysystemusb2usb.usb2usb import usb2usb
try:
   u2u = usb2usb(sys.argv[1])
   u2u.backup()
except yaml.YAMLError:
   exit()

You can create a service systemd if you planed to backup your usb key evry day in the morning. You can wakeonlan from a raspberrypi or other technique

wakeonlan MACADRESS
crontab -e
# write your cron
sudo service cron reload

Now for create a daemon in startup (without console).

Use this name “backupmysystemusb2usb” because in source const.py this file is a const for GUI progress for non-root user

cd /etc/systemd/system
vi backupmysystemusb2usb.service

Write

[Unit]
After=ssh.service

[Service]
WorkingDirectory=/your/working/path/
ExecStart=/usr/bin/sh -c "/your/working/path/run.py /your/working/path/config.yml"

[Install]
WantedBy=default.target

Enable and start

sudo systemctl daemon-reload
sudo systemctl enable backupmysystemusb2usb

Then the service start on reboot. If you will test now the service :

sudo systemctl start backupmysystemusb2usb

Check the log (no detail just the command like dd)

sudo journalctl --unit backupmysystemusb2usb -n 20

You can go to check your ouput log file configured by config.yml

Now we have to create the shell return for non-root user gui.py

touch gui.py
chmod 700 gui.py
vi gui.py

And write in file

#!/usr/bin/env python3
import yaml
from backupmysystemusb2usb.usb2usb import usb2usb
u2u = usb2usb('/path/to/your/config.yml')
u2u.gui()

You can create a autostart Gnome desktop startup

cd ~/.config/autostart
touch backupmysystemusb2usb.desktop
chmod 744
vi backupmysystemusb2usb.desktop

And in your editor enter

[Desktop Entry]
Name=Backup my system usb to usb
Comment=Copy disk with the same space
Exec=/your/working/path/gui.py
Icon=org.gnome.Terminal
Path=/your/working/path/
Terminal=true
Hidden=false
Type=Application
Categories=Utility;Application;

Installation from source

To install the latest developpement version run the following command:

git clone https://github.com/stephaneworkspace/backupmysystemusb2usb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backupmysystemusb2usb-1.0.2.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file backupmysystemusb2usb-1.0.2.tar.gz.

File metadata

  • Download URL: backupmysystemusb2usb-1.0.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/2.7.17

File hashes

Hashes for backupmysystemusb2usb-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d065277d604642e8ccc77f3e693265be45ae3ea744c2f273a6928be26cbf7c04
MD5 def62161396f83eb5744fc28fc15bd90
BLAKE2b-256 1ebb8b3953ca74bc6fd8afda16af6e4afd2eba360fced5a8f27d487e4a36b526

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page