Code Monkey home page Code Monkey logo

bsync's Introduction

bsync

Bsync is a bidirectional file synchronization tool, using rsync for transfers. Moved files are also synchronized in a smart way.

It uses rsync for file transfers, GNU find to generate filelist snapshots, and ssh for remote transfers.

bsync is an alternative to Unison, written in Python 3. A big strength of bsync: it can detect and apply moved files from one side to the other (Unison uses some copy calls to handle moved files).

I developped it to be able to synchronize my music directory from my laptop to my Raspberry Pi in an efficient way, and to sync with my girlfriend laptop too.

Bsync is released under GPL. Feel free to report any bugs/wishes in GitHub issues.

Install

wget https://raw.github.com/dooblem/bsync/master/bsync
chmod +x bsync

For remote syncing: don't forget to install rsync.

Usage

Fairly simple:

./bsync DIRECTORY1 DIRECTORY2
./bsync ALICE_DIR  bob@sshserver:BOB_DIR

bsync can also be used to sync with a master directory:

# Alice makes local changes
./bsync ALICE_DIR MASTER_DIR
./bsync BOB_DIR   MASTER_DIR
# Bob gets Alice changes, sending his changes to master in the same time

bsync help and options:

Usage: bsync [options] DIR1 DIR2

	DIR can be user@sshserver:DIR
	-v              Verbose
	-i              Ignore permissions
	-p PORT         Port for SSH
	-o SSHARGS      Custom options for SSH

Features

  • Moved files detection (using inodes numbers)
  • Remote directories using SSH
  • No problem with symlinks or permissions
  • Conflict detection
  • Python not needed on remote side (just GNU find and rsync)
  • Exclude some subdirectories from sync (just create a .bsync-ignore file)
  • Move your sync dirs without loosing sync memory (filelists stored inside directories in .bsync-snap-* files)
  • Auto disable permissions on fat filesystems
  • MacOSX support (requirement: GNU find installed)

Limitations:

  • files ownership ignored (would matter if syncing from root user, but sufficient for regular users)
  • no subdir conflict detection (a bit like in git where only files matter, no conflict is detected if dir1/dir/ removed and dir2/dir/file created the other side)
  • No Windows support
  • Not tested under: OpenBSD, FreeBSD (any feedback appreciated)

Example

$ ./bsync dir1 dir2
Loading filelists...
dir1                        dir2                   
new                    -->                         (copy)
subdir/a               -->  subdir/a               (sync)
                       <--  newdir/                (mkdir)
                       <--  newdir/newfile         (copy)
Apply actions? [y/N] y
Applying actions...
rsync: new
rsync: subdir/a
rsync: newdir/newfile
Updating filelists...
Done!

$ ./bsync dir1 dir2
Loading filelists...
Identical directories. Nothing to do.

Conflict handling

Bsync prompts the user for conflicts.

A sample run with a conflict: file deleted one side and updated the other side.

$ bsync dir1/ dir2/
Loading filelists...

Conflicting changes on: testfile
*deleted*                           <?>   -rw-r--r-- 7B (2014-01-30 18:47:40) (conflict)
Which one do I keep [1/2/?] ?
	1	Keep left version
	2	Keep right version
	1a	Keep left version for all
	2a	Keep right version for all
Which one do I keep [1/2/?] 2
dir1/                                    dir2/                               
                                    <--  testfile                            (copy)
Apply actions? [y/N] y
Applying actions...
rsync: testfile
Updating filelists...
Done!

.bsync-ignore files

You can add directories/files paths in a .bsync-ignore file located at the root of a sync directory. Every path in it will be ignored when syncing with other dirs. You can also see that as a mask for the synchronization.

Say, if I have a dir1/.bsync-ignore file with content:

path/to/ignoredir
path/to/ignorefile

dir1/path/to/ignoredir (+content) and dir1/path/to/ignorefile will be ignored in the next bsync runs.

The ignore file has to be very simple. No comments, just path prefixes.

See also

My blog

bsync's People

Contributors

dooblem avatar coreagile avatar alexalouit avatar

Stargazers

Pierre Alouit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.