Copy Smartermail Directories on Linux using Rsync


This KB article will detail how administrators can leverage Rsync, an open source file-transfer tool, to create copies of server data. While Robocopy is our utility of choice for taking copies of server data on Windows Operating Systems, Rsync is perfect for Linux users due to its inclusion in most common distros.

There are a few situations in which you could find yourself using Rsync while administering a SmarterMail server, like when migrating data between servers or taking copies for support purposes. While support agents will usually request a config-only copy, which is often sufficient to reproduce issues locally, during a migration you’d likely want to take a full backup of the domain or account which you are migrating.


Full Copy

To retrieve a full copy of an entire domain, or even an individual user, use the following command:

sudo rsync -r __PATH TO SOURCE__ __PATH TO DESTINATION__

For example, to generate a full copy of a domain (domain.com) to a dedicated folder in the home directory, you could run the following:

sudo rsync -r /var/lib/SmarterMail/Domains/domain.com /home/user/staging/domain.com-fullbackup

To copy a user rather than a full domain (e.g., user@domain.com), the source would look something like this:

/var/lib/SmarterMail/Domains/domain.com/Users/user

Uses of a Full Copy

  • Migrations of multiple domains’ data/settings
  • Migrations of single domain’s data/settings
  • Migrations of individual user’s data/settings


Config-Only Copy

A config-only copy is a copy of a domain or a user’s account that excludes any email, file storage, stats, or indexing data. Config-only copies are our preferred solution to replicate customer environments locally without putting sensitive data at risk. To retrieve a config-only copy, use the following command:

sudo rsync -r --exclude='*.grp' --exclude='*.stat' --exclude '*/IndexV2/’ --exclude '*/FileStore/' __PATH TO SOURCE__ __PATH TO DESTINATION__

For example, to perform a config-only copy of domain.com to your home directory, you’d use the following:

sudo rsync -r --exclude='*.grp' --exclude='*.stat' --exclude '*/IndexV2/’ --exclude '*/FileStore/' /var/lib/SmarterMail/Domains/domain.com /home/user/staging/domain.com-ConfigOnlyBackup

The Config-Only copy will strip out the following, seen in the exclusions:

  • email files (.GRP files)
  •  stat files (.STAT files)
  •  Indexing folder (/IndexV2)
  •  Local file storage folder (/FileStore)

Uses of a Config-Only Copy

  • Assist support agents with replications
  • Migrate settings for domains/users
  • Separate mail data from configuration data


Preparing the Copy

You might want to compress the copy before sending it, depending on your use case. To do so, you can run the following command:

sudo zip -r __NAME OF DESTINATION__ __PATH TO SOURCE__

For example, to compress the newly copied domain.com-ConfigOnlyBackup to the ‘compressed’ folder in the home directory:

sudo zip -r /home/user/compressed /home/user/staging/domain.com-ConfigOnlyBackup

At this point you just need to use the solution of your choice to upload/download the compressed copy of the domain.