docs/src/introduction.md

changeset 283
0e36bb75a732
parent 273
c743721d566f
equal deleted inserted replaced
282:3070d72f54af 283:0e36bb75a732
1 ---
2 title: 'Introduction to dav-sync'
3 ---
4
5 The dav-sync program can synchronize a local directory with a WebDAV collection.
6
7 First Steps
8 -----------
9
10 To use dav-sync it is required to configure a repository in [config.xml][1] and the directory in [sync.xml][2].
11
12 Create a repository with [dav add-repository][3]. Unlike *dav*, *dav-sync* is not interactive and never shows an authentication prompt. Therefore the user and password **must** be specified if the server requires authentication.
13
14 $ dav add-repository
15 Each repository must have an unique name.
16 name: myfirstrepo
17
18 Specify the repository base url.
19 url: http://example.com/webdav/
20
21 User for HTTP authentication.
22 user (optional): myuser
23 password (optional):
24
25 After the repository is created, configure a sync-directory with [dav-sync add-directory][4].
26
27 $ dav-sync add-directory
28 Each sync directory must have an unique name.
29 name: mysyncdir
30 Enter local directory path.
31 path: $HOME/important_files
32 Specify webdav repository.
33 0) myfirstrepo
34 1) anotherrepo
35 repository: 0
36 Enter collection relative to the repository base url.
37 collection (default: /): /important_files
38
39 The specified name is just an identifier and will be used with other dav-sync commands like *pull* and *push*.
40
41 After the configuration is created, you can synchronize your files. There are two commands for it: *pull* and *push*.
42
43 With *pull* you can apply all changes on the server to your local directory. The command scans the server and detects modified files and which files are deleted. All modified files will be downloadet and all deleted files will be locally removed (or moved to the trash directory). The first time you will run *pull* for a directory this will just download all files from the WebDAV collection.
44
45 You can run the *pull* command with:
46
47 dav-sync pull mysyncdir
48
49 The *push* command scans your local directory for changes, uploads all modified files and removes all locally deleted files from the server.
50
51 dav-sync push mysyncdir
52
53 [1]: ./configuration.html
54 [2]: ./sync-configuration.html
55 [3]: ./add-repository.html
56 [4]: ./add-directory.html
57
58
59 Database
60 --------
61
62 Every sync-directory has a database xml file that contains the etag and last modified date of each file. The etag is used to detect changes on the server and the last modified date is used to detect local changes. The database file is usually located in *$HOME/.dav/* and if you want to reset a sync-directory, you can delete the database. After that, *pull*/*push* (with disabled conflict detection) will download/upload all files.
63
64
65 Conflict detection
66 ------------------
67
68 The *pull* and *push* commands detect if a file has changed remotely and locally. This is a conflict that must be resolved manually.
69
70 When *pull* detects a conflict it renames the local file to *orig-\$number.\$name* where *\$number* is an integer, usually 0 if no other conflict file with the name exists and *\$name* is the file's name. After the file is renamed the new file from the server is downloadet. The user should merge the files manually then or just delete one or keep both. After that run *resolve-conflicts* to remove all conflict entries from the database otherwise *push* will ignore any file in a conflict state. There is also the *delete-conflicts* command that deletes all conflict files.
71
72 When *push* detects that a file is modified locally and on the server, it just skips this file. Run the *pull* command to get the new file from the server and resolve the conflict like described above.
73
74
75
76 Trash
77 -----
78
79 For high data safety, a trash directory can be configured. If this is done, dav-sync will not delete files, but move them to the trash directory. Also the pull command can move files to the trash directory before overwriting them.
80
81 To enable the trash, add the `<trash>` element to the directory config. The trash path can be absolute or relative to the sync-directory path.
82
83 <directory>
84 <name>mydir</name>
85 <path>$HOME/myfiles</path>
86 <repository>myrepo</repository>
87 <database>mydir-db.xml</database>
88
89 <!-- enable trash dir -->
90 <trash>.trash</trash>
91 </directory>
92
93 Files inside the trash directory will not be synchronized with the server.
94
95 Add the `<backup-on-pull>` element if you want to backup files to the trash directory before they are overwritten.
96
97 <directory>
98 ...
99
100 <backup-on-pull>true</backup-on-pull>
101 <directory>
102
103
104 Locking
105 -------
106
107 It is highly recommended to lock the repository if it is expected that multiple users want to access and modify the repository simultaneously. Locking can be enabled with the `-l` option when using the *pull* or *push* command, or it can be permanently enabled in *sync.xml* for a directory with the `<lock-pull>` and `<lock-push>` elements.
108
109 <directory>
110 ...
111 <lock-pull>true</lock-pull>
112 <lock-push>true</lock-push>
113 </directory>
114
115 See [Configuration][5] for details.
116
117 [5]: ./configuration.html
118
119 Encryption
120 ----------
121
122 The *dav-sync* program uses the same repository settings as *dav*. If encryption is enabled for a repository, *dav-sync* stores files encrypted on the server. See [Encryption][6] for details.
123
124 [6]: ./encryption.html
125

mercurial