Code Monkey home page Code Monkey logo

pybkup2usb's Introduction

pybkup2usb

pybkup2usb is a python module to simplify backing up a folder or file(s) to a USB flash drive on any OS platform.

Quick Start

Install from GitHub:

$ git clone https://github.com/djacobson/pybkup2usb
$ cd pybkup2usb
$ pip3 install -e .

Run the following command, with and without a USB flash drive plugged into your computer:

> bkup2usb stuff_to_backup

...or, to run directly from source (i.e.: skipping the pip3 install above):

> python3 -m pybkup2usb stuff_to_backup

Add a prefix to your backup target:

> bkup2usb stuff_to_backup -p MyID

Also, simply type bkup2usb -h for help with parameters.

Using in your application code is as simple as the following lines of code (prefix is optional):

from pybkup2usb import bkup2usb

retstatus, retmsg = bkup2usb.backup(bkupsource, prefix='MyID')

About

The original objective of this module was to make something surprisingly complex easy, and accomplish the following:

  • Automatically discover the path to the first available USB flash drive (if one is plugged in)
  • Backup some files to it
  • That's it!

Simple right? ...except do this on any OS platform with Python, and abstract away as much complexity as possible. Seriously, all I wanted to do was the above! You'd think something like that would be pretty straight-forward... :/

To Do

  • Version 1, it works. :)

  • If like me, you are building a dedicated device for a single-purpose app, and interested in using this USB function (i.e.: your app) as the single user interface to the USB flash drive + backup, you may be interested in disabling / suppressing the general desktop feature of automatically launching the File Manager app after inserting and automounting a USB flash drive. Below is a possible solution...

    For Ubuntu:

    gsettings set org.gnome.desktop.media-handling automount-open false Credit: ish

    I'm still looking for an equivalent solution for Raspbian's Gnome desktop.

Dependencies

For Posix OSs (i.e.: Linux / Ubuntu, Raspbian, MacOS, etc.):

  • pyudev
  • psutil

For Windows:

  • pywin32

Tests

  • Platforms tested: Python 3.6 on Raspbian, Ubuntu 18.10, Windows 10

Authors, Contributors, etc.

Version 1 of pybkup2usb was designed and written by David Jacobson (github), but, the base functionality is really just an encapsulation of the generous public forum contributions of Howard Lightstone for the Windows USB code, and the excellent StackExchange answer contributed by Michael Daffin and Arjuna for the Posix USB code.

pybkup2usb's People

Contributors

djacobson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.