TrueNAS SCALETrueNAS SCALE Nightly Development Documentation
This content follows experimental early release software. Use the Product and Version selectors above to view content specific to a stable software release.

Configuring Rsync Tasks

Rsync provides fast incremental data transfer to synchronize files between a TrueNAS host and a remote system. The Push function copies data from TrueNAS to a remote system. The Pull function copies data from a remote system and stores it in the defined Path on the TrueNAS host system.

There are two ways to connect to a remote system and run an rsync task: setting up an SSH connection to the remote server or an rsync module on the remote server.

Configuring SSH Mode Rsync Tasks

Before you create an rsync task in SSH mode, add an SSH connection and keypair between the TrueNAS host and remote system. See Adding SSH Credentials for more information.

After setting up the SSH connection, configure the rsync task on the TrueNAS host.

Setting up an SSH Connection

  1. Enable SSH on the remote system.

  2. Enable SSH in TrueNAS. Go to System > Services and toggle SSH on.

  3. Add an SSH connection to the remote server. Go to Credentials > Backup Credentials and use SSH Connections and SSH Keypairs.

    Populate the SSH Connections configuration fields as follows:

    TrueNAS Host to TrueNAS Remote

    a. Select Semi-automatic (TrueNAS only) in Setup Method.
    b. Enter the remote TrueNAS URL.
    c. Fill in the remaining credentials for this TrueNAS to authenticate to the remote TrueNAS and exchange SSH keys.
    d. Select Generate New in Private Key.
    e. Enter a number of seconds for TrueNAS to attempt the connection before timing out and closing the connection.

    TrueNAS Host to Non-TrueNAS Remote

    a. Select Manual in Setup Method.
    b. Enter the remote host name, port number, and user in the appropriate fields.
    c. Select Generate New in Private Key or click Discover Remote Host Key to connect to the remote system and automatically populate the Remote Host Key field.
    d. Enter a number of seconds for TrueNAS to attempt the connection before timing out and closing the connection.

    Click Save. If you generated a new keypair, click on SSH Keypairs to download the public and private keys. TrueNAS automatically adds the public key to Authorized Keys for the admin user.

  4. Add the keypair and SSH connection to the remote system.

    If the remote system is another TrueNAS SCALE system, go to Credentials > Backup Credentials and add the keypair first. Paste in the public and private keys that you created on the host. Then create the SSH connection as above. Select the new key from the Private Key dropdown.

  5. Go to Credentials > Local Users, select the admin user, and click Edit. Check Authentication to ensure the SSH public key is present. If needed, paste the public key in Authorized Keys or click Choose File then browse to and upload the public key file.

    (Optional) If selecting SSH private key stored in user’s home directory for Connect Using in the rsync task configuration, add the private key to the home directory for the user to perform the task. For the admin user, the default location is /home/admin/.ssh/private_key.

  6. If not already present, add the public key to the home directory of the remote user with permission to write to the destination dataset. Follow the procedure above for remote TrueNAS SCALE systems.

    (Optional) If selecting SSH private key stored in user’s home directory for Connect Using in the rsync task configuration, add the private key to the home directory for the remote user.

Creating an SSH Mode Rsync Task

  1. Go to Data Protection and click Add on the Rsync Tasks widget to open the Add Rsync Task screen.
Add Rsync Task - SSH Mode
Figure 1: Add Rsync Task - SSH Mode
  1. Enter or browse to the dataset or folder to sync with the remote server. Use the arrow_right to the left of the /mnt folder and each folder listed on the tree to expand and browse through, then click on the name to populate the path field.

    Browsing to select a path

    Click the arrow to the left of the folder icon to expand that folder and show any child datasets and directories. A solid folder icon shows for datasets and an outlined folder for directories. A selected dataset or directory folder and name shows in blue.

  2. Select a User account to perform the rsync task. The user must have permissions to run an rsync on the remote server and read/write permission for the local dataset.

  3. Set the Direction for the rsync task. Select Pull to copy from the remote server to TrueNAS or Push to copy to the remote server.

  4. Select SSH as the connection mode from the Rsync Mode dropdown. The SSH settings fields show.

  5. Choose a connection method from the Connect using dropdown list.

    If selecting SSH private key stored in user’s home directory, enter the IP address or hostname of the remote system in Remote Host. Use the format username@remote_host if the username differs on the remote host. Enter the SSH port number for the remote system in Remote SSH Port. By default, 22 is reserved in TrueNAS.

    If selecting SSH connection from the keychain, select an existing SSH connection to a remote system or choose Create New to add a new SSH connection.

  6. Enter in Remote Path the full path to a location on the remote server to pull from or push to. Maximum path length is 255 characters.

    If the remote path location does not exist, select Validate Remote Path to create and define it in Remote Path.

  7. Set the schedule for when to run this task, and any other options you want to use.

    If you need a custom schedule, select Custom to open the advanced scheduler window.

    Advanced Scheduler

    DataProtectionSMARTTestAdvancedSchedSCALE

    Choosing a Presets option populates in the rest of the fields. To customize a schedule, enter crontab values for the Minutes/Hours/Days.

    These fields accept standard cron values. The simplest option is to enter a single number in the field. The task runs when the time value matches that number. For example, entering 10 means that the job runs when the time is ten minutes past the hour.

    An asterisk (*) means match all values.

    You can set specific time ranges by entering hyphenated number values. For example, entering 30-35 in the Minutes field sets the task to run at minutes 30, 31, 32, 33, 34, and 35.

    You can also enter lists of values. Enter individual values separated by a comma (,). For example, entering 1,14 in the Hours field means the task runs at 1:00 AM (0100) and 2:00 PM (1400).

    A slash (/) designates a step value. For example, entering * in Days runs the task every day of the month. Entering */2 runs it every other day.

    Combining the above examples creates a schedule running a task each minute from 1:30-1:35 AM and 2:30-2:35 PM every other day.

    TrueNAS has an option to select which Months the task runs. Leaving each month unset is the same as selecting every month.

    The Days of Week schedules the task to run on specific days in addition to any listed days. For example, entering 1 in Days and setting Wed for Days of Week creates a schedule that starts a task on the first day of the month and every Wednesday of the month.

    The Schedule Preview displays when the current settings mean the task runs.

    Examples of CRON syntax

    SyntaxMeaningExamples
    *Every item.* (minutes) = every minute of the hour.
    * (days) = every day.
    */NEvery Nth item.*/15 (minutes) = every 15th minute of the hour.
    */3 (days) = every 3rd day.
    */3 (months) = every 3rd month.
    Comma and hyphen/dashEach stated item (comma)
    Each item in a range (hyphen/dash).
    1,31 (minutes) = on the 1st and 31st minute of the hour.
    1-3,31 (minutes) = on the 1st to 3rd minutes inclusive, and the 31st minute, of the hour.
    mon-fri (days) = every Monday to Friday inclusive (every weekday).
    mar,jun,sep,dec (months) = every March, June, September, December.

    You can specify days of the month or days of the week.

    TrueNAS lets users create flexible schedules using the available options. The table below has some examples:

    Desired scheduleValues to enter
    3 times a day (at midnight, 08:00 and 16:00)months=*; days=*; hours=0/8 or 0,8,16; minutes=0
    (Meaning: every day of every month, when hours=0/8/16 and minutes=0)
    Every Monday/Wednesday/Friday, at 8.30 pmmonths=*; days=mon,wed,fri; hours=20; minutes=30
    1st and 15th day of the month, during October to June, at 00:01 ammonths=oct-dec,jan-jun; days=1,15; hours=0; minutes=1
    Every 15 minutes during the working week, which is 8am - 7pm (08:00 - 19:00) Monday to FridayNote that this requires two tasks to achieve:
    (1) months=*; days=mon-fri; hours=8-18; minutes=*/15
    (2) months=*; days=mon-fri; hours=19; minutes=0
    We need the second scheduled item, to execute at 19:00, otherwise we would stop at 18:45. Another workaround would be to stop at 18:45 or 19:45 rather than 19:00.

  8. Select the Enabled to enable the task. Leave cleared to disable the task but not delete the configuration. You can still run the rsync task by going to Data Protection and clicking then the Run Now icon for the rsync task.

  9. Click Save.

Configuring Module Mode Rsync Tasks

Before you create an rsync task in module mode, you must define at least one module per rsyncd.conf(5) on the remote rsync server. The Rsync Daemon application is available in situations where configuring TrueNAS as an rsync server with an rsync module is necessary.

After configuring the rsync server, configure the rsync task.

Defining an Rsync Module

If the non-TruNAS remote server includes an rsync service, make sure it is turned on.

  1. Create a dataset on the remote TrueNAS (or other system). Write down the host and path to the data on the remote system you plan to sync with.

  2. Create a module on the remote system. On TrueNAS, install an rsync app (such as Rsyncd) and configure the module.

Creating a Module Mode Rsync Task

  1. Go to Data Protection and click Add on the Rsync Tasks widget to open the Add Rsync Task screen.
Add Rsync Task - Module Mode
Figure 4: Add Rsync Task - Module Mode
  1. Enter or browse to the dataset or folder to sync with the remote server. Use the arrow_right to the left of the /mnt folder and each folder listed on the tree to expand and browse through, then click on the name to populate the path field.

    Browsing to select a path

    Click the arrow to the left of the folder icon to expand that folder and show any child datasets and directories. A solid folder icon shows for datasets and an outlined folder for directories. A selected dataset or directory folder and name shows in blue.

  2. Select a User account to perform the rsync task. The user must have permissions to run an rsync on the remote server and read/write permission for the local dataset.

  3. Set the Direction for the rsync task. Select Pull to copy from the remote server to TrueNAS or Push to copy to the remote server.

  4. Select Module as the connection mode from the Rsync Mode dropdown. The module settings fields show.

  5. Enter the remote host name or IP in Remote Host. Use the format username@remote_host when the username differs from the host entered into the Remote Host field.

  6. Set the schedule for when to run this task, and any other options you want to use.

    If you need a custom schedule, select Custom to open the advanced scheduler window.

    Advanced Scheduler

    DataProtectionSMARTTestAdvancedSchedSCALE

    Choosing a Presets option populates in the rest of the fields. To customize a schedule, enter crontab values for the Minutes/Hours/Days.

    These fields accept standard cron values. The simplest option is to enter a single number in the field. The task runs when the time value matches that number. For example, entering 10 means that the job runs when the time is ten minutes past the hour.

    An asterisk (*) means match all values.

    You can set specific time ranges by entering hyphenated number values. For example, entering 30-35 in the Minutes field sets the task to run at minutes 30, 31, 32, 33, 34, and 35.

    You can also enter lists of values. Enter individual values separated by a comma (,). For example, entering 1,14 in the Hours field means the task runs at 1:00 AM (0100) and 2:00 PM (1400).

    A slash (/) designates a step value. For example, entering * in Days runs the task every day of the month. Entering */2 runs it every other day.

    Combining the above examples creates a schedule running a task each minute from 1:30-1:35 AM and 2:30-2:35 PM every other day.

    TrueNAS has an option to select which Months the task runs. Leaving each month unset is the same as selecting every month.

    The Days of Week schedules the task to run on specific days in addition to any listed days. For example, entering 1 in Days and setting Wed for Days of Week creates a schedule that starts a task on the first day of the month and every Wednesday of the month.

    The Schedule Preview displays when the current settings mean the task runs.

    Examples of CRON syntax

    SyntaxMeaningExamples
    *Every item.* (minutes) = every minute of the hour.
    * (days) = every day.
    */NEvery Nth item.*/15 (minutes) = every 15th minute of the hour.
    */3 (days) = every 3rd day.
    */3 (months) = every 3rd month.
    Comma and hyphen/dashEach stated item (comma)
    Each item in a range (hyphen/dash).
    1,31 (minutes) = on the 1st and 31st minute of the hour.
    1-3,31 (minutes) = on the 1st to 3rd minutes inclusive, and the 31st minute, of the hour.
    mon-fri (days) = every Monday to Friday inclusive (every weekday).
    mar,jun,sep,dec (months) = every March, June, September, December.

    You can specify days of the month or days of the week.

    TrueNAS lets users create flexible schedules using the available options. The table below has some examples:

    Desired scheduleValues to enter
    3 times a day (at midnight, 08:00 and 16:00)months=*; days=*; hours=0/8 or 0,8,16; minutes=0
    (Meaning: every day of every month, when hours=0/8/16 and minutes=0)
    Every Monday/Wednesday/Friday, at 8.30 pmmonths=*; days=mon,wed,fri; hours=20; minutes=30
    1st and 15th day of the month, during October to June, at 00:01 ammonths=oct-dec,jan-jun; days=1,15; hours=0; minutes=1
    Every 15 minutes during the working week, which is 8am - 7pm (08:00 - 19:00) Monday to FridayNote that this requires two tasks to achieve:
    (1) months=*; days=mon-fri; hours=8-18; minutes=*/15
    (2) months=*; days=mon-fri; hours=19; minutes=0
    We need the second scheduled item, to execute at 19:00, otherwise we would stop at 18:45. Another workaround would be to stop at 18:45 or 19:45 rather than 19:00.

  7. Select the Enabled to enable the task. Leave cleared to disable the task but not delete the configuration. You can still run the rsync task by going to Data Protection and clicking then the Run Now icon for the rsync task.

  8. Click Save.