1 |
I've been using rsync to sync binary files, shell scripts, my |
2 |
workspace, and random user files under my home directory across |
3 |
multiple machines. I'm using one server as the master copy, which |
4 |
makes daily incremental backups of my files to a separate disk with |
5 |
rsync. At the moment, I have my sync script set up as a Makefile with |
6 |
the following targets. I run this from multiple workstations. |
7 |
|
8 |
It would be nice to use something as easy as svn, but many of my files |
9 |
are binary. Or something like dropbox would be great. I don't work |
10 |
from windows, so I don't need a cross-platform solution. |
11 |
|
12 |
What utilities do you guys use? Is there a better way to do this? It |
13 |
would be nice to move everything to the background, but I've already |
14 |
clobbered a few files by calling this in the wrong order and might |
15 |
move the Makefile to an interactive script to protect against that. I |
16 |
have to call 'make clobber' after I remove a local file to push that |
17 |
change to the server, and if I forgot to call 'make get' first, I have |
18 |
to fix it manually. |
19 |
|
20 |
-------sync makefile-------- |
21 |
get: |
22 |
rsync -azOuvihh --progress -e ssh $(EXCLUDE) \ |
23 |
--delete \ |
24 |
$(HOST):$(SERVER_DIR) $(LOCAL_DIR) |
25 |
|
26 |
put: |
27 |
rsync -azOuvihh --progress -e ssh $(EXCLUDE) \ |
28 |
$(LOCAL_DIR) $(HOST):$(SERVER_DIR) |
29 |
|
30 |
clobber: |
31 |
rsync -azOuvihh --progress -e ssh $(EXCLUDE) \ |
32 |
--delete \ |
33 |
$(LOCAL_DIR) $(HOST):$(SERVER_DIR) |
34 |
------end------- |
35 |
|
36 |
-------backup script-------- |
37 |
# if files are already there, hard link |
38 |
# the last lines mark it as complete and move a soft link pointer |
39 |
rsync -zavi --progress --delete \ |
40 |
--link-dest=$BACKUP_PATH/current \ |
41 |
$SOURCE $BACKUP_PATH/backup_part_$DATE \ |
42 |
&& mv $BACKUP_PATH/backup_part_$DATE $BACKUP_PATH/backup_$DATE \ |
43 |
&& unlink $BACKUP_PATH/current \ |
44 |
&& ln -s $BACKUP_PATH/backup_$DATE $BACKUP_PATH/current |
45 |
-------end--------- |
46 |
|
47 |
Randy |