Tag: rsync

Supply password to rsync

Supply password to rsync

Via environment variable

Use environment variable RSYNC_PASSWORD to provide password to rsync command

rsync -zvr source destination


env RSYNC_PASSWORD=$PASSWORD rsync -zvr source destination

Via password file

rsync --password-file=rsync_pass -zvr source destination

Some other methods

Such as sshpass and public key.


How can I rsync without prompt for password, without using public key authentication?

Rsync backup client

Rsync backup client

Rsync backup command can be used as below.

rsync -avR --delete
        --backup-dir=/folder-`date +%Y.%m.%d` \
        --password-file=/root/password_file \
        --exclude-from='exclude-list.txt' \
        /app \
        /usr/local/share/ca-certificates/ \
        /etc/network/interfaces \
        /etc/NetworkManager/system-connections/ \
        /root \
        /home \

The password_file only contains rsync password without any other data.

In rsync@server::NetBackup/folder, rsync is user id, server is rsync server, NetBackup is rsync service (share folder), folder is where backup to be saved.

The backup-dir is the folder created in the rsync server to save changes.

Configure rsync in TrueNAS

Configure rsync in TrueNAS

Create user/group

Create a user called rsync, with group rsync.

Create dataset

Create a dataset, owned by rsync:rsync, with permission 770.

Enable rsync service

Go to System Settings -> Services, enable rsync.

Create module

Click on Configure (Edit icon), select Rsync Module tab, key in following info, and save configuration.

  • Module Name
  • Access Mode: Read & Write
  • User: rsync
  • Group: rsync


Run following command from remote server

rsync -avR --password-file=/root/.rsync/password \
    /tmp \

Rsync Basic

Rsync Basic

rsync a directory to a new directory with different name

A trailing slash on the source avoids creating an additional directory level at the destination.

rsync -a src/ dest

You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name".

Show progress

rsync -a -P src dest
rsync -a --progress src dest

Issue with rsync duplicate filesystem

Issue with rsync duplicate filesystem

Some issues encountered when using rsync to duplicate filesystem.

Extended attribute

When duplicating the files, rsync didn't take care of extended attributes, users might lose rights on some files.

Sparse files (Untested)

In order to create/update sparse files, to steps required.

To create new files in sparse mode

rsync --ignore-existing --sparse ...

To update all existing files (including the previously created sparse ones) inplace.

rsync --inplace ...