Skip to main content

Advanced directory tree synchronisation tool

Project description

© 2014 Thomas Khyn © 2003 Anand B Pillai

Advanced directory tree synchronisation tool

based on Python robocopier by Anand B Pillai

Usage

From the command line:

dirsync <sourcedir> <targetdir> [options]

From python:

from dirsync import sync
sync(sourcedir, targetdir, action, **options)

Main Options

Chosing one option among the following ones is mandatory

--diff, -d

Only report difference between sourcedir and targetdir

--sync, -s

Synchronize content between sourcedir and targetdir

--update, -u

Update existing content between sourcedir and targetdir

If you use one of the above options (e.g. sync) most of the time, you may consider defining the action option in a Configuration file parsed by dirsync.

Additional Options

--verbose, -v

Provide verbose output

--purge, -p

Purge files when synchronizing (does not purge by default)

--force, -f

Force copying of files, by trying to change file permissions

--nodirection, -n

Update files in source directory from target directory (only updates target from source by default)

--create, -c

Create target directory if it does not exist (By default, target directory should exist.)

--modtime, -m

Only compare file’s modification times for an update (By default, compares source file’s creation time also)

--ignore, -x patterns

Regex patterns to ignore

--only, -o patterns

Regex patterns to include (exclude every other)

--exclude, -e patterns

Regex patterns to exclude

--include, -i patterns

Regex patterns to include (with precedence over excludes)

Configuration file

If you want to use predefined options all the time, or if you need specific options when ‘dirsyncing’ a specific source directory, dirsync looks for two configuration files, by order or priority (the last takes precedence):

%HOME%/.dirsync
source/directory/.dirsync

The command line options always override the values defined in the configuration files.

The configuration files must have a defaults section, and the options are as defined above. The only exception is for the option action, which can take 3 values diff, sync or update.

Example config file:

[defaults]
action = sync
create = True

Custom logger

From python, you may not want to have the output sent to stdout. To do so, you can simply pass your custom logger via the logger keyword argument of the sync function:

sync(sourcedir, targetdir, action, logger=my_logger, **options)

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

dirsync-2.1.zip (15.5 kB view details)

Uploaded Source

Built Distribution

dirsync-2.1-py2.7.egg (19.8 kB view details)

Uploaded Source

File details

Details for the file dirsync-2.1.zip.

File metadata

  • Download URL: dirsync-2.1.zip
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dirsync-2.1.zip
Algorithm Hash digest
SHA256 21465c468efde86daef1ddfa7924e07933f08621aef17d0789ded69dc0ee1952
MD5 acd5101e7b018821d78558383462bd6d
BLAKE2b-256 fae153b0693072ed01ebee6023d99e9484259ceab5878cc58bbe168c17b62f93

See more details on using hashes here.

File details

Details for the file dirsync-2.1-py2.7.egg.

File metadata

  • Download URL: dirsync-2.1-py2.7.egg
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dirsync-2.1-py2.7.egg
Algorithm Hash digest
SHA256 2964708a7f314450b20ac1a4519b5995523e544c13657123af4955345192c849
MD5 29ec9c00569fec8568b8980b28c138cc
BLAKE2b-256 9afb08a6edec9e481cefb4f911ac94f7a9f44b16dbd2af2d59bfe88998437450

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