Skip to main content

© 2014+ Thomas Khyn © 2003-2015 Anand B Pillai

Advanced directory tree synchronisation tool

based on Python robocopier by Anand B Pillai

If you like dirsync and find it useful, you may want to thank me and encourage future development by sending a few mBTC / mBCH / mBSV at this address: 1EwENyR8RV6tMc1hsLTkPURtn5wJgaBfG9.

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

--twoway, -2

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.)

--ctime

Also takes into account the source file's creation time (Windows) or the source file's last metadata change (Unix)

--content

Takes into account ONLY content of files. Synchronize ONLY different files. At two-way synchronization source files content have priority if destination and source are existed

--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):

~/.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)

Release files for dirsync 2.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dirsync 2.2.6
File Size Uploaded
dirsync-2.2.6.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dirsync 2.2.6
File Interpreter ABI Platform
dirsync-2.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / dirsync-2.2.6.tar.gz

Download URL dirsync-2.2.6.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
53b557ec5b54bda19c155cd04d7bb935f8b4a74450985f22a9f555a0360570bc
BLAKE2b-256 checksum
How to use checksums
57039f3435a81035191727f1846783c8598971160172a50fc551b8e799d4eece
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / dirsync-2.2.6-py3-none-any.whl

Download URL dirsync-2.2.6-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88fe72cfcf4d1a6ad307d40439a84e7156b5b3816f1b3ec6b6ff71528e0c807a
BLAKE2b-256 checksum
How to use checksums
eb1c270c0648c40f6996ccd38572d2c707acab44c590fc339475c5f13249011b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

2.2.6 This release

2 release files

2.2.5

1 release file

2.2.4

1 release file

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2

1 release file

2.1

2 release files

2.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page