Skip to main content

backupper for uploading and managing files in ownCloud.

Project description

ownCloud backup

This project is used for uploading the backups to the ownCloud and managing old backups.

How it works

By default, script expects one file argument, which will be uploaded to ownCloud with %Y.%m.%d_ time prefix into remote_path directory.

When the file is uploaded, scripts requests listing of all other files in selected remote_path, then reads time informations from names and then removes old files.

Process of removing of old files is defined to keep following files:

  • all files from last month

  • one file per week for two-months-before

  • one file per two weeks for three-months-before

and to remove all older files.

Configuration

There is possibility of configuration of following variables using conf files owncloud_backup.cfg or ~/.owncloud_backup.cfg:

[Login]
user=login@owncloud.tld
pass=password
url=https://owncloud.cesnet.cz

[Config]
remote_path=/backups
no_timestamp=false

All values in Config section and url variable from Login section is optional (defaults are shown in this example).

no_timestamp will instruct the script to stop putting the timestamp prefix to uploaded files. In that case, it is expected that such files will contain the timestamp added manually, or they will be ignored in process of elimination of old files.

Commandline arguments

All variables defined in configuration file may be also added using commandline arguments:

usage: owncloud_backup.py [-h] [-u USERNAME] [-p PASSWORD] [--url URL]
                          [-r REMOTE_PATH] [-n]
                          FILENAME

This program may be used to perform database backups into ownCloud.
Configuration file in ini format is expected in `owncloud_backup.cfg` or
`~/.owncloud_backup.cfg` paths.

positional arguments:
  FILENAME              Upload FILENAME into the ownCloud.

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        Username of the ownCloud user.
  -p PASSWORD, --password PASSWORD
                        Password of the ownCloud user.
  --url URL             URL of the ownCloud service. Default
                        `https://owncloud.cesnet.cz`.
  -r REMOTE_PATH, --remote-path REMOTE_PATH
                        Path on the server. Default `/backups`.
  -n, --no-timestamp    By default, the script adds `%Y.%m.%d_` prefix to each
                        uploaded file.

Installation

Module is hosted at PYPI, and can be installed using PIP:

sudo pip install owncloud_backup

Installation on SuSe

In case that you are using ancient Suse installation with old python versions and no PIP, you may install it with following commands:

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-20.0.zip
unzip setuptools-20.0.zip
cd setuptools-20.0/
python setup.py install
easy_install pip==1.2
pip install -U owncloud_backup

Source code

Project is released under the MIT license. Source code can be found at GitHub:

Unittests

Almost every feature of the project is tested by unittests. You can run those tests using provided run_tests.sh script, which can be found in the root of the project.

If you have any trouble, just add --pdb switch at the end of your run_tests.sh command like this: ./run_tests.sh --pdb. This will drop you to PDB shell.

Requirements

This script expects that packages pytest is installed. In case you don’t have it yet, it can be easily installed using following command:

pip install --user pytest

or for all users:

sudo pip install pytest
Example
./run_tests.sh
============================= test session starts ==============================
platform linux2 -- Python 2.7.6, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/bystrousak/Plocha/Dropbox/c0d3z/prace/owncloud_backup, inifile:
plugins: cov-1.8.1
collected 3 items

tests/test_backup.py ...

=========================== 3 passed in 0.47 seconds ===========================

Changelog

0.1.6

  • Fixed bug in removing old files on remote server.

0.1.5

  • Added mute of the InsecurePlatformWarning.

0.1.4

  • Fixed bugs in argument parsing priority.

0.1.3

  • Added few other python2.6 updates.

0.1.2

  • Removed set comprehension to support python2.6.

0.1.1

  • Added scripts declaration into setup.py.

0.1.0

  • Project created.

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

owncloud_backup-0.1.6.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file owncloud_backup-0.1.6.tar.gz.

File metadata

File hashes

Hashes for owncloud_backup-0.1.6.tar.gz
Algorithm Hash digest
SHA256 06ab173840971ed6f157a80c44e4a51148c37449618b9e95a3c27434906c1386
MD5 83dd548cc77014c9b6745df62ef8de22
BLAKE2b-256 917fabf3289834cc7de9dcda21022417469e1ea8cacfa41e1b8f67ef6f83d88a

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