Synchronization

Copyright 2018 Brian Davis - CC-BY-NC-SA

There are several protocols that I use to copy data between machines. The first is the simplest to setup: SSH. SSH comes preinstalled with most Linux distributions, although you sometimes have to install the server component. It allows shell access and file transfer.

ssh username@host
scp file username@host:/path/to/destination

Samba

Samba is the Linux server that is compatable with Windows File Sharing. You can setup a samba server to share a folder in your Linux system with your other Linux or Windows computers.

First install the packages: samba, samba-client, and cifs-utils. Then add the following section to the end of /etc/samba/smb.conf

[share]
   comment = Shared Files
   path = /home/share
   browseable = yes
   read only = no
   guest ok = no
   valid users = filesharer

Alternatively setup [homes] to only read/write access and change the path with something like

path = /home/data/%S

List shares

smbclient -L \\hostname
smbclient -L \\IP

Mount a share

sudo mount -t cifs //host/share /mnt/dest -o user=username

A possible fstab entry (UNTESTED)

//192.168.0.10/Files /mnt/Files cifs auto,x-systemd.automount,cache=none,rsize=130048,wsize=57344,users,username=brian,password={mypassword},workgroup=WORKGROUP,ip=192.168.0.10 0 0

Note: If you are mounting a homes share you refer to it as //host/username.

Note on Users: Samba has it's own user/password database that must mirror the unix passwd.

sudo smbpasswd -a <username>

Webdav

Webdav is a filesharing protocol that uses HTTP. You setup an apache webserver and then configure it for webdav.

TODO:

Rsync

Rsync is the utility that most people use to synchronize lots of files between Linux computers. There is such a thing as an rsync server but my normal use case is to mount a remote filesystem (using fuse if necessary) and then use rsync on the local machine between the two filesystems. Once gotcha is the path name syntax. To sync a local folder blob to a remote folde /mnt/foo/blob you want to make sure you use the trailing slash on the source but not the destination.

rsync -r blob/ /mnt/foo/blob

# --delete will remove files on the receiver that do not exist locally
# -a = recursive and preserve permissions/modification times
# -P = allow resume of partials
# --modify-window=2 helps with ntfs timestamp issues
# -u skips newer files on the receiver
rsync -auPv --modify-window=2 --delete ~/me/cur/ ~/h/cur