skip to navigation
skip to content

Not Logged In

dirsync 2.1

Advanced directory tree synchronisation tool

Latest Version: 2.2

© 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

<kbd>--diff, -d</kbd> Only report difference between sourcedir and targetdir
<kbd>--sync, -s</kbd> Synchronize content between sourcedir and targetdir
<kbd>--update, -u</kbd> 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

<kbd>--verbose, -v</kbd> Provide verbose output
<kbd>--purge, -p</kbd> Purge files when synchronizing (does not purge by default)
<kbd>--force, -f</kbd> Force copying of files, by trying to change file permissions
<kbd>--nodirection, -n</kbd>
 Update files in source directory from target directory (only updates target from source by default)
<kbd>--create, -c</kbd> Create target directory if it does not exist (By default, target directory should exist.)
<kbd>--modtime, -m</kbd> Only compare file’s modification times for an update (By default, compares source file’s creation time also)
<kbd>--ignore, -x <var>patterns</var></kbd>
 Regex patterns to ignore
<kbd>--only, -o <var>patterns</var></kbd>
 Regex patterns to include (exclude every other)
<kbd>--exclude, -e <var>patterns</var></kbd>
 Regex patterns to exclude
<kbd>--include, -i <var>patterns</var></kbd>
 Regex patterns to include (with precedence over excludes)

Configuration file

Note

Configuration files are only used when using the command line, and ignored when dirsync is called from within Python.

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

Warning

Any source/directory/.dirsync file is automatically excluded from the files to compare. You have to explicitly include using the --include option it if you want it to be covered by the comparison.

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)
 
File Type Py Version Uploaded on Size
dirsync-2.1-py2.7.egg (md5) Python Egg 2.7 2014-08-09 19KB
dirsync-2.1.zip (md5) Source 2014-08-09 15KB
  • Downloads (All Versions):
  • 47 downloads in the last day
  • 212 downloads in the last week
  • 776 downloads in the last month