aboutsummaryrefslogtreecommitdiff

AutoSync

AutoSync is a tiny utility to synchronize data between computers.

Dependencies

  • python >= 3.6
  • rsync

How-to

Install me

You can install this directly as a python package using the pip3 command, like this:

pip3 install git+https://git.art-software.fr/electron/AutoSync.git

You can prepend the url with --user to make it install into your user path (~/.local/bin for the binary and ~/.local/lib/python3.x/site-packages/ for the rest) If you wish to install system-wide, think about running pip3 as root.

Add --upgrade to upgrade the package when needed.

Get help

You can invoke AutoSync (we'll write asc from here, it's shorter :) ) with no option to let it list for you all that you can do with it (or you can see below)

File format

asc uses a file in which you indicate a folder to synchronize, where to synchronize it and a name. The format is quite simple:

targetname        source_path        target_path

Caution: only use tab character between columns, not spaces!

Both source and target path can be local or start with [user@]host: prefix, in which case rsync will use SSH. You can use ~ notation as well as shell variables in the given paths.

You should put one item per line, as many lines as you wish.

The file must be located either at ~/.autoSync.tab (in which case its name will be "@default" for asc) or at ~/.autoSync.whateveryouwant.tab, in which case asc will see it as @whateveryouwant.

Address targets

To synchronize

To tell asc to synchronize a given item in a given tabfile, you should use:

asc @tabname target1 target2

and it will automatically sync all given targets.

@tabname is what we saw earlier: it corresponds to the file in which you listed your targets (@tabname corresponds to ~/.autoSync.tabname.tab) target1 and target2 are names in the first column in this file.

If you wish to synchronize every target, you simply invoke:

asc @target

To list available targets

You can ask asc to list all available tabfiles without even having to use ls or these sort of things by invoking asc with only a single at (@) sign:

asc @

It will list all @tabname you can use, even the "default" one if the file ~/.autoSync.tab exists.

To list all targets available for a given tabfile, just calls asc with its name while doubling the at sign, like this:

asc @@tabname

Server mode

Sometimes, you can want to setup a secondary sync server, but tell asc not to take the local data as if you were on a working computer (ie data is not likely to be modified in place directly). In this case, you can prepend the @tabname with a -s switch.

Before every sending sync and after every receiving sync, asc updates the source timestamp to keep track of which version is more recent. The "server mode" prevents it from doing it, which will parasite a secondary server repository (because if you sync from a server to another, the server1 will update timestamps as if you had worked on the local copy, which you did not)

Ignore items

If you wish to tell asc to ignore certain items inside some of your targets, you can create a .ignore.lst file inside the root folder of the source path and list inside every item that you wish to be ignored. You can prepend ** to mean "any length of file name or folders", as well as common glob notation (* to mean "any length of any characters" or ? for "any single character"), one target per line.

See man 1 rsync, section "FILTER RULES" for more info on this file's rules format.

Logging

What asc does is automatically written in the file ~/.autoSync.log, which you can read to know what operations have been done in the past.

You can set the environment variable LOGLEVEL to instruct asc to only log certain events. Log levels are incremental, which means if you set it to a certain level, it will log everything that falls after this value.

  • 0: DEBUG. Detailed information about what happens inside.
  • 1: INFO.
  • 2: NOTIF. Less verbose than INFO
  • 3: WARN. Only warnings and errors
  • 4: ERROR. Only fatal errors.