Skip to content

Commit c5ef7a9

Browse files
authored
Merge branch 'deajan:master' into kerberos-patch
2 parents f0d9cfc + 548f3c5 commit c5ef7a9

File tree

4 files changed

+122
-79
lines changed

4 files changed

+122
-79
lines changed

README.md

Lines changed: 100 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
[![macos tests](https://github.com/deajan/osync/actions/workflows/macos.yml/badge.svg)](https://github.com/deajan/osync/actions/workflows/macos.yml/badge.svg)
99

1010

11-
A two way filesync script running on bash Linux, BSD, Android, MacOSX, Cygwin, MSYS2, Win10 bash and virtually any system supporting bash).
12-
File synchronization is bidirectional, and can be run manually, as scheduled task, or triggered on file changes in daemon mode.
11+
A two way filesync script running on bash Linux, BSD, Android, MacOSX, Cygwin, MSYS2, Win10 bash and virtually any system supporting bash.
12+
File synchronization is bidirectional, and can be run manually, as scheduled task, or triggered on file changes in monitor mode.
1313
It is a command line tool rsync wrapper with a lot of additional features baked in.
1414

15-
This is a quickstart guide, you can find the full documentation on the author's site.
15+
This is a quickstart guide, you can find the full documentation on the [author's site](http://www.netpower.fr/osync).
1616

1717
## About
1818

19-
osync provides the following capabilities
19+
osync provides the following capabilities:
2020

2121
- Local-Local and Local-Remote sync
2222
- Fault tolerance with resume scenarios
2323
- POSIX ACL and extended attributes synchronization
2424
- Full script Time control
2525
- Soft deletions and multiple backups handling
26-
- Before / after run command execution
26+
- Before/after run command execution
2727
- Email alerts
2828
- Logging facility
2929
- Directory monitoring
@@ -33,33 +33,50 @@ osync provides the following capabilities
3333
osync is a stateful synchronizer. This means it's agentless and doesn't have to monitor files for changes. Instead, it compares replica file lists between two runs.
3434
A full run takes about 2 seconds on a local-local replication and about 7 seconds on a local-remote replication.
3535
Disabling some features file like attributes preservation and disk space checks may speed up execution.
36-
osync uses a initiator / target sync schema. It can sync local to local or local to remote directories. By definition, initiator replica is always a local directory on the system osync runs on.
37-
osync uses pidlocks to prevent multiple concurrent sync processes on/to the same initiator / target replica.
36+
osync uses a initiator/target sync schema. It can sync local to local or local to remote directories. By definition, initiator replica is always a local directory on the system osync runs on.
37+
osync uses pidlocks to prevent multiple concurrent sync processes on/to the same initiator/target replica.
3838
You may launch concurrent sync processes on the same system but as long as the replicas to synchronize are different.
3939
Multiple osync tasks may be launched sequentially by osync osync-batch tool.
4040

41-
Currently, it has been tested on CentOS 5.x, 6.x, 7.x, AlmaLinux 9, Fedora 22-25, Debian 6-11, Linux Mint 14-18, Ubuntu 12.04-22.04, FreeBSD 8.3-11, Mac OS X, QTS 4.5.1(x86) and pfSense 2.3.x.
42-
Microsoft Windows is supported via MSYS, Cygwin and or via WSL.
43-
Android support works via Termux.
44-
Some users also have successfully used osync on Gentoo and created an openRC init scriptt for it.
41+
## Tested platforms
42+
43+
| Operating system | Version |
44+
|------------------|------------------------|
45+
| AlmaLinux | 9 |
46+
| Android\* | Not known |
47+
| CentOS | 5.x, 6.x, 7.x |
48+
| Fedora | 22-25 |
49+
| FreeBSD | 8.3-11 |
50+
| Debian | 6-11 |
51+
| Linux Mint | 14-18 |
52+
| macOS | Not known |
53+
| pfSense | 2.3.x |
54+
| QTS (x86) | 4.5.1 |
55+
| Ubuntu | 12.04-22.04 |
56+
| Windows\*\* | 10 |
57+
58+
\* via Termux.
59+
\*\* via MSYS, Cygwin and WSL.
60+
61+
Some users also have successfully used osync on Gentoo and created an OpenRC init script for it.
4562

4663
## Installation
4764

4865
osync has been designed to not delete any data, but rather make backups of conflictual files or soft deletes.
4966
Nevertheless, you should always have a neat backup of your data before trying a new sync tool.
5067

51-
Getting osync via github (remove the -b "stable" if you want latest dev snapshot)
68+
Getting osync via GitHub (remove the -b "stable" if you want latest dev snapshot)
5269

5370
$ git clone -b "stable" https://github.com/deajan/osync
5471
$ cd osync
5572
$ bash install.sh
5673

5774
Installer script accepts some parameters for automation. Launch install.sh --help for options.
5875

59-
There is also a RPM file that should fit RHEL/CentOS/Fedora and basically any RPM based distro, see the github release.
60-
Please note that RPM files will install osync to /usr/bin instead of /usr/local/bin in order to enforce good practices.
76+
There is also an RPM file that should fit RHEL/CentOS/Fedora and basically any RPM based distro, see the GitHub release.
77+
Please note that RPM files will install osync to `/usr/bin` instead of `/usr/local/bin` in order to enforce good practices.
6178

62-
osync will install itself to /usr/local/bin and an example configuration file will be installed to /etc/osync
79+
osync will install itself to `/usr/local/bin` and an example configuration file will be installed to `/etc/osync`.
6380

6481
osync needs to run with bash shell. Using any other shell will most probably result in errors.
6582
If bash is not your default shell, you may invoke it using
@@ -70,7 +87,7 @@ On *BSD and BusyBox, be sure to have bash installed.
7087

7188
If you can't install osync, you may just copy osync.sh where you needed and run it from there.
7289

73-
Archlinux packages are available at <https://aur.archlinux.org/packages/osync/> (thanks to Shadowigor, <https://github.com/shadowigor>)
90+
Arch Linux packages are available at <https://aur.archlinux.org/packages/osync/> (thanks to Shadowigor, <https://github.com/shadowigor>).
7491

7592
## Upgrade from previous configuration files
7693

@@ -86,99 +103,113 @@ The script will backup your config file, update it's content and try to connect
86103

87104
## Usage
88105

89-
Osync can work with in three flavors: Quick sync mode, configuration file mode, and daemon mode.
90-
While quick sync mode is convenient to do fast syncs between some directories, a configuration file gives much more functionnality.
91-
Please use double quotes as path delimiters. Do not use escaped characters in path names.
106+
Osync can work in 3 modes:
107+
1. [:rocket: Quick sync mode](#quick-sync-mode)
108+
2. [:gear: Configuration file mode](#configuration-file-mode)
109+
3. [:mag_right: Monitor mode](#monitor-mode)
92110

93-
## QuickSync example
111+
> [!NOTE]
112+
> Please use double quotes as path delimiters. Do not use escaped characters in path names.
113+
114+
### <a id="quick-sync-mode"></a>:rocket: Quick sync mode
115+
116+
Quick sync mode is convenient to do fast syncs between some directories. However, the [configuration file mode](#configuration-file-mode) gives much more functionality.
94117

95118
# osync.sh --initiator="/path/to/dir1" --target="/path/to/remote dir2"
96119
# osync.sh --initiator="/path/to/another dir" --target="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa_private_key_example.com
97120

98-
## Summary mode
121+
#### Quick sync with minimal options
122+
123+
In order to run osync the quickest (without transferring file attributes, without softdeletion, without prior space checks and without remote connectivity checks, you may use the following:
124+
125+
# MINIMUM_SPACE=0 PRESERVE_ACL=no PRESERVE_XATTR=no SOFT_DELETE_DAYS=0 CONFLICT_BACKUP_DAYS=0 REMOTE_HOST_PING=no osync.sh --initiator="/path/to/another dir" --target="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa_private_key_example.com
126+
127+
All the settings described here may also be configured in the conf file.
128+
129+
### Summary mode
99130

100-
osync may output only file changes and errors with the following
131+
osync will output only file changes and errors with the following:
101132

102133
# osync.sh --initiator="/path/to/dir1" --target="/path/to/dir" --summary --errors-only --no-prefix
103134

104135
This also works in configuration file mode.
105136

106-
## QuickSync with minimal options
137+
### <a id="configuration-file-mode"></a>:gear: Configuration file mode
107138

108-
In order to run osync the quickest (without transferring file attributes, without softdeletion, without prior space checks and without remote connectivity checks, you may use the following:
109-
110-
# MINIMUM_SPACE=0 PRESERVE_ACL=no PRESERVE_XATTR=no SOFT_DELETE_DAYS=0 CONFLICT_BACKUP_DAYS=0 REMOTE_HOST_PING=no osync.sh --initiator="/path/to/another dir" --target="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa_private_key_example.com
139+
You'll have to customize the `sync.conf` file according to your needs.
111140

112-
All the settings described here may also be configured in the conf file.
141+
If you intend to sync a remote directory, osync will need a pair of private/public RSA keys to perform remote SSH connections. Also, running sync as superuser requires to configure the `/etc/sudoers` file.
113142

114-
## Running osync with a Configuration file
143+
> [!TIP]
144+
> Read the [example configuration file](https://github.com/deajan/osync/blob/master/sync.conf.example) for documentation about remote sync setups.
115145
116-
You'll have to customize the sync.conf file according to your needs.
117-
If you intend to sync a remote directory, osync will need a pair of private / public RSA keys to perform remote SSH connections.
118-
Also, running sync as superuser requires to configure /etc/sudoers file.
119-
Please read the documentation about remote sync setups.
120-
Once you've customized a sync.conf file, you may run osync with the following test run:
146+
Once you've customized a `sync.conf` file, you may run osync with the following test run:
121147

122148
# osync.sh /path/to/your.conf --dry
123149

124-
If everything went well, you may run the actual configuration with one of the following:
150+
If everything went well, you may run the actual configuration with:
125151

126152
# osync.sh /path/to/your.conf
153+
154+
To display which files and attrs are actually synchronized and which files are to be soft deleted / are in conflict, use `--verbose` (you may mix it with `--silent` to output verbose input only in the log files):
155+
127156
# osync.sh /path/to/your.conf --verbose
128-
# osync.sh /path/to/your.conf --no-maxtime
129157

130-
Verbose option will display which files and attrs are actually synchronized and which files are to be soft deleted / are in conflict.
131-
You may mix "--silent" and "--verbose" parameters to output verbose input only in the log files.
132-
No-Maxtime option will disable execution time checks, which is usefull for big initial sync tasks that might take long time. Next runs should then only propagate changes and take much less time.
158+
Use `--no-maxtime` to disable execution time checks, which is usefull for big initial sync tasks that might take long time. Next runs should then only propagate changes and take much less time:
159+
160+
# osync.sh /path/to/your.conf --no-maxtime
133161

134-
Once you're confident about your first runs, you may add osync as a cron task like the following in /etc/crontab which would run osync every 30 minutes:
162+
Once you're confident about your first runs, you may add osync as a cron task like the following in `/etc/crontab` which would run osync every 30 minutes:
135163

136164
*/30 * * * * root /usr/local/bin/osync.sh /etc/osync/my_sync.conf --silent
137165

138-
Please note that this syntax works for RedHat / CentOS. On Debian you might want to remove the username (ie root) in order to make the crontab entry work.
166+
Please note that this syntax works for RedHat/CentOS. On Debian you might want to remove the username (i.e. root) in order to make the crontab entry work.
139167

140-
## Batch mode
168+
### Batch mode
141169

142-
You may want to sequentially run multiple sync sets between the same servers. In that case, osync-batch.sh is a nice tool that will run every osync conf file, and, if a task fails,
170+
You may want to sequentially run multiple sync sets between the same servers. In that case, `osync-batch.sh` is a nice tool that will run every osync conf file, and, if a task fails,
143171
run it again if there's still some time left.
144-
The following example will run all .conf files found in /etc/osync, and retry 3 times every configuration that fails, if the whole sequential run took less than 2 hours.
172+
173+
To run all `.conf` files found in `/etc/osync`, and retry 3 times every configuration that fails if the whole sequential run took less than 2 hours, use:
145174

146175
# osync-batch.sh --path=/etc/osync --max-retries=3 --max-exec-time=7200
147176

148177
Having multiple conf files can then be run in a single cron command like
149178

150179
00 00 * * * root /usr/local/bin/osync-batch.sh --path=/etc/osync --silent
151180

152-
## Daemon mode
181+
### <a id="monitor-mode"></a>:mag_right: Monitor mode
153182

154-
Additionaly, you may run osync in monitor mode, which means it will perform a sync upon file operations on initiator replica.
155-
This can be a drawback on functionnality versus scheduled mode because this mode only launches a sync task if there are file modifications on the initiator replica, without being able to monitor the target replica.
156-
Target replica changes are only synced when initiator replica changes occur, or when a given amount of time (default 600 seconds) passed without any changes on initiator replica.
157-
File monitor mode can also be launched as a daemon with an init script. Please read the documentation for more info.
158-
Note that monitoring changes requires inotifywait command (inotify-tools package for most Linux distributions).
159-
BSD, MacOS X and Windows are not yet supported for this operation mode, unless you find a inotify-tools package on these OSes.
183+
> [!NOTE]
184+
> Monitoring changes requires inotifywait command (`inotify-tools` package for most Linux distributions). BSD, macOS and Windows are not yet supported for this operation mode, unless you find an `inotify-tool` package on these OSes.
160185
161-
# osync.sh /etc/osync/my_sync.conf --on-changes
186+
Monitor mode will perform a sync upon file operations on initiator replica. This can be a drawback on functionality versus scheduled mode because this mode only launches a sync task if there are file modifications on the initiator replica, without being able to monitor the target replica. Target replica changes are only synced when initiator replica changes occur, or when a given amount of time (600 seconds by default) passed without any changes on initiator replica.
187+
188+
This mode can also be launched as a daemon with an init script. Please read the documentation for more info.
189+
190+
To use this mode, use `--on-changes`:
162191

163-
Osync file monitor mode may be run as system service with the osync-srv script.
164-
You may run the install.sh script which should work in most cases or copy the files by hand (osync.sh to /usr/bin/local, sync.conf to /etc/osync, osync-srv to /etc/init.d for initV, osync-srv@.service to /usr/lib/systemd/system for systemd, osync-srv-openrc to /etc/init.d/osync-srv-openrc for OpenRC).
192+
# osync.sh /etc/osync/my_sync.conf --on-changes
165193

166-
InitV specific instructions:
194+
To run this mode as a system service with the `osync-srv` script, you can run the `install.sh` script (which should work in most cases) or copy the files by hand:
195+
- `osync.sh` to `/usr/bin/local`
196+
- `sync.conf` to `/etc/osync`
197+
- For InitV, `osync-srv` to `/etc/init.d`
198+
- For systemd, `osync-srv@.service` to `/usr/lib/systemd/system`
199+
- For OpenRC, `osync-srv-openrc` to `/etc/init.d/osync-srv-openrc`
167200

168-
Any configuration file found in /etc/osync will create a osync daemon instance when service is launched on initV with:
201+
For InitV (any configuration file found in `/etc/osync` will create an osync daemon instance when service is launched on initV):
169202

170203
$ service osync-srv start
171204
$ chkconfig osync-srv on
172205

173-
Systemd specific (one service per config file)
206+
For systemd, launch service (one service per config file to launch) with:
174207

175-
Launch service (one service per config file to launch) with:
176208
$ systemctl start osync-srv@configfile.conf
177209
$ systemctl enable osync-srv@configfile.conf
178210

179-
OpenRC specific instructions (user contrib)
211+
For OpenRC (user contrib), launch service (one service per config file to launch) with:
180212

181-
Launch service (one service per config file to launch) with:
182213
$ rc-update add osync-srv.configfile default
183214

184215
## Security enhancements
@@ -190,21 +221,24 @@ Please read full documentation in order to configure ssh filter.
190221

191222
All kind of contribs are welcome.
192223

193-
When submitting a PR, please be sure to modify files in dev directory (dev/n_osync.sh, dev/ofunctions.sh, dev/common_install.sh etc) as most of the main files are generated via merge.sh.
224+
When submitting a PR, please be sure to modify files in dev directory (`dev/n_osync.sh`, `dev/ofunctions.sh`, `dev/common_install.sh etc`) as most of the main files are generated via merge.sh.
194225
When testing your contribs, generate files via merge.sh or use bootstrap.sh which generates a temporary version of n_osync.sh with all includes.
195226

196-
Unit tests are run by travis on every PR, but you may also run them manually which adds some tests that travis can't do, via dev/tests/run_tests.sh
197-
SSH port can be changed on the fly via environment variable SSH_PORT, eg: SSH_PORT=2222 dev/tests/run_tests.sh
227+
Unit tests are run by travis on every PR, but you may also run them manually which adds some tests that travis can't do, via `dev/tests/run_tests.sh`.
228+
SSH port can be changed on the fly via environment variable SSH_PORT, e.g.:
229+
230+
# SSH_PORT=2222 dev/tests/run_tests.sh
198231

199232
Consider reading CODING_CONVENTIONS.TXT before submitting a patch.
200233

201234
## Troubleshooting
202235

203-
You may find osync's logs in `/var/log/osync.[INSTANCE_ID].log` (or current directory if /var/log is not writable).
236+
You may find osync's logs in `/var/log/osync.[INSTANCE_ID].log` (or current directory if `/var/log` is not writable).
204237
Additionnaly, you can use the --verbose flag see to what actions are going on.
205238

206-
When opening an issue, please post the corresponding log files. Also, you may run osync with _DEBUG option in order to have more precise logs, eg:
207-
_DEBUG=yes ./osync.sh /path/to/conf
239+
When opening an issue, please post the corresponding log files. Also, you may run osync with _DEBUG option in order to have more precise logs, e.g.:
240+
241+
# _DEBUG=yes ./osync.sh /path/to/conf
208242

209243
## Uninstalling
210244

@@ -214,5 +248,5 @@ The installer script also has an uninstall mode that will keep configuration fil
214248

215249
## Author
216250

217-
Feel free to open an issue on github or mail me for support in my spare time :)
251+
Feel free to open an issue on GitHub or mail me for support in my spare time :)
218252
Orsiris de Jong | ozy@netpower.fr

dev/debug_osync.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ function SendAlert {
504504
fi
505505

506506
if [ $runAlert == true ]; then
507-
subject="Currently runing - $subject"
507+
subject="Currently running - $subject"
508508
else
509509
subject="Finished run - $subject"
510510
fi

dev/ofunctions.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ else
8282
_LOGGER_VERBOSE=true
8383
fi
8484

85-
if [ "$SLEEP_TIME" == "" ]; then # Leave the possibity to set SLEEP_TIME as environment variable when runinng with bash -x in order to avoid spamming console
85+
if [ "$SLEEP_TIME" == "" ]; then # Leave the possibility to set SLEEP_TIME as environment variable when running with bash -x in order to avoid spamming console
8686
SLEEP_TIME=.05
8787
fi
8888
#### DEBUG SUBSET END ####
@@ -512,7 +512,7 @@ function SendAlert {
512512
fi
513513

514514
if [ $runAlert == true ]; then
515-
subject="Currently runing - $subject"
515+
subject="Currently running - $subject"
516516
else
517517
subject="Finished run - $subject"
518518
fi
@@ -786,7 +786,7 @@ function _PerfProfiler { #__WITH_PARANOIA_DEBUG
786786

787787
_OFUNCTIONS_SPINNER="|/-\\"
788788
function Spinner {
789-
if [ $_LOGGER_SILENT == true ] || [ "$_LOGGER_ERR_ONLY" == true ] || [ "$_SYNC_ON_CHANGES" == "initiator" ] || [ "$_SYNC_ON_CHANGES" == "target" ] ; then
789+
if [ "$_LOGGER_SILENT" == true ] || [ "$_LOGGER_ERR_ONLY" == true ] || [ "$_SYNC_ON_CHANGES" == "initiator" ] || [ "$_SYNC_ON_CHANGES" == "target" ] ; then
790790
return 0
791791
else
792792
printf " [%c] \b\b\b\b\b\b" "$_OFUNCTIONS_SPINNER"

0 commit comments

Comments
 (0)