Skip to main content

Synchronize files from and to host systems.

Project description

file sync tool

PyPI - Python Version PyPI Scrutinizer Code Quality Build Status

Python script to synchronize files from an origin to a target system using rsync.

This tool is an addon of the db-sync-tool.

Installation

Prerequisite

The script needs python 3.5 or higher. It is necessary for some additional functionalities to have pip installed on your local machine.

pip

The library can be installed from PyPI:

$ pip3 install file-sync-tool-kmi

composer

The script is also available via packagist.org using composer:

$ composer require kmi/file-sync-tool

Additionally install the python requirements via the following pip command:

$ pip3 install -e vendor/kmi/file-sync-tool/

Configuration

You can configure the script with shell arguments or using a separate configuration file.

Configuration File

The config.json contains important information about the origin and the target system.

Example structure of config.json in receiver mode :

{
  "target": {},
  "origin": {
    "host": "ssh_host",
    "user": "ssh_user"
  },
  "files": {
    "config": [
      {
        "origin": "/var/www/html/files/",
        "target": "/var/www/html/files/",
        "exclude": [
          "*.log"
        ]
      }
    ]
  }
}

Documentation

For further information see the documentation of the db-sync-tool.

Usage

Command line

Run the python script via command line.

Installed via pip:

$ python3 file_sync_tool

Installed via composer:

$ python3 vendor/kmi/file-sync-tool/file_sync_tool

Shell arguments

usage: file_sync_tool [-h] [-f CONFIG_FILE] [-v] [-m] [-o HOST_FILE]

A tool for automatic file synchronization from and to host systems.

optional arguments:
  -h, --help            show this help message and exit
  -f CONFIG_FILE, --config-file CONFIG_FILE
                        Path to configuration file
  -v, --verbose         Enable extended console output
  -m, --mute            Mute console output
  -o HOST_FILE, --host-file HOST_FILE
                        Using an additional hosts file for merging hosts
                        information with the configuration file

If you haven't declare a path to a SSH key, during the script execution you are requested to enter the SSH password for the given user in the shell argument or the config.json to enable a SSH connection for the remote system.

Import

You can import the python package and use them inside your project:

from file_sync_tool import sync

if __name__ == "__main__":
    sync.Sync(config={}, args*)

Build

The packaging process of the python module is described on python.org.

Tests

A docker container set up is available for testing purpose. See here.

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

file_sync_tool-kmi-0.1.0.tar.gz (9.0 kB view hashes)

Uploaded Source

Built Distribution

file_sync_tool_kmi-0.1.0-py3-none-any.whl (10.4 kB view hashes)

Uploaded Python 3

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