You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
13
13
It is a command line tool rsync wrapper with a lot of additional features baked in.
14
14
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).
16
16
17
17
## About
18
18
19
-
osync provides the following capabilities
19
+
osync provides the following capabilities:
20
20
21
21
- Local-Local and Local-Remote sync
22
22
- Fault tolerance with resume scenarios
23
23
- POSIX ACL and extended attributes synchronization
24
24
- Full script Time control
25
25
- Soft deletions and multiple backups handling
26
-
- Before / after run command execution
26
+
- Before/after run command execution
27
27
- Email alerts
28
28
- Logging facility
29
29
- Directory monitoring
@@ -33,33 +33,50 @@ osync provides the following capabilities
33
33
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.
34
34
A full run takes about 2 seconds on a local-local replication and about 7 seconds on a local-remote replication.
35
35
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.
38
38
You may launch concurrent sync processes on the same system but as long as the replicas to synchronize are different.
39
39
Multiple osync tasks may be launched sequentially by osync osync-batch tool.
40
40
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.
45
62
46
63
## Installation
47
64
48
65
osync has been designed to not delete any data, but rather make backups of conflictual files or soft deletes.
49
66
Nevertheless, you should always have a neat backup of your data before trying a new sync tool.
50
67
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)
Quick sync mode is convenient to do fast syncs between some directories. However, the [configuration file mode](#configuration-file-mode) gives much more functionality.
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:
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:
You'll have to customize the `sync.conf` file according to your needs.
111
140
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.
113
142
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.
115
145
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:
121
147
122
148
# osync.sh /path/to/your.conf --dry
123
149
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:
125
151
126
152
# 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
+
127
156
# osync.sh /path/to/your.conf --verbose
128
-
# osync.sh /path/to/your.conf --no-maxtime
129
157
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
133
161
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:
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.
139
167
140
-
## Batch mode
168
+
###Batch mode
141
169
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,
143
171
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:
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.
160
185
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`:
162
191
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
165
193
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`
167
200
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):
169
202
170
203
$ service osync-srv start
171
204
$ chkconfig osync-srv on
172
205
173
-
Systemd specific (one service per config file)
206
+
For systemd, launch service (one service per config file to launch) with:
174
207
175
-
Launch service (one service per config file to launch) with:
176
208
$ systemctl start osync-srv@configfile.conf
177
209
$ systemctl enable osync-srv@configfile.conf
178
210
179
-
OpenRC specific instructions (user contrib)
211
+
For OpenRC (user contrib), launch service (one service per config file to launch) with:
180
212
181
-
Launch service (one service per config file to launch) with:
182
213
$ rc-update add osync-srv.configfile default
183
214
184
215
## Security enhancements
@@ -190,21 +221,24 @@ Please read full documentation in order to configure ssh filter.
190
221
191
222
All kind of contribs are welcome.
192
223
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.
194
225
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.
195
226
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
198
231
199
232
Consider reading CODING_CONVENTIONS.TXT before submitting a patch.
200
233
201
234
## Troubleshooting
202
235
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).
204
237
Additionnaly, you can use the --verbose flag see to what actions are going on.
205
238
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
208
242
209
243
## Uninstalling
210
244
@@ -214,5 +248,5 @@ The installer script also has an uninstall mode that will keep configuration fil
214
248
215
249
## Author
216
250
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 :)
Copy file name to clipboardExpand all lines: dev/ofunctions.sh
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ else
82
82
_LOGGER_VERBOSE=true
83
83
fi
84
84
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
86
86
SLEEP_TIME=.05
87
87
fi
88
88
#### DEBUG SUBSET END ####
@@ -512,7 +512,7 @@ function SendAlert {
512
512
fi
513
513
514
514
if [ $runAlert==true ];then
515
-
subject="Currently runing - $subject"
515
+
subject="Currently running - $subject"
516
516
else
517
517
subject="Finished run - $subject"
518
518
fi
@@ -786,7 +786,7 @@ function _PerfProfiler { #__WITH_PARANOIA_DEBUG
0 commit comments