Mail and snapshots

Hi all,
Just a quick question. Since I host my email server within HestiaCP, when working on my server (a VPS), I take a snapshot before making radical updates on changes/installs. This way I can revert quickly to the state of the machine before my tinkering.
Now if I work, say, for 4 hours, emails may arrive in the meantime. Reverting to the snapshot will lose those new emails, right?
Is there a way to kind of backup the current SMPT server before snapshot restore and then put it back with the new messages?

Thanks for any clue.
Steve J

Ofcourse, you can - and should - do this always. This is compulsory.

You simply need to take a backup by using the command:

v-backup-user Username

and then save the backup on your computer or laptop at home, or store on a different VPS. Then, bring the latest backup back to the restored VPS (from the snapshot) and put it in the /backup directory. Thereafter, restore this last backup of that user (or even under a new user) into the new VPS with the following command:

v-restore-user Username Username-xx-xx-xx-xx-xx-xx

After doing this, you will import everything that was under that Username’s account into the restored and newly created VPS.

I have done this a thousand times.

One note while restoring:

The backup and restore scripts are not really buggy but they are not very well developed. They create heaps of problems over a period of time, if there were changes in versions of Hestia, etc. So during the restore, the restore script will try to restart the apache2/nginx and throw an error.

Thereafter, the restore scripts are too stupid to crash because it did not - or could n ot - restart the apache2/nginx. Thus, the restore process will not continue to restore other areas like DB, mail, etc.

The problem of restore scripts is in the insufficient or defective logic of these scripts and they are not buggy. Here is a very simple solution of this crash:

Restore twice!

After the first crash during the restore, the second attempt of restoring the same backup data will be successful, if it was due to apache2 and nginx reload problem.

As this solution is so tiny, I have never taken time to post a message here thinking that perhaphs I was the only one.

2 Likes

Thanks for our input.
Unfortunately, that won’t work, because it will restore everything, not only the mail servers.
If I restore my server to the snapshot, then the hestia backup will restore all other settings I may have screwed.
Is there a particular folder to backup in order to restore only emails?

Steve

You can restore only the mail part from the backup:

v-restore-user USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY]

The key here is to use '*' on 5th argument and no on the rest of arguments.

Example:

User: sjordi
Backup file name in dir /backup/: sjordi.2024-10-02_19-51-37.tar

v-restore-user sjordi sjordi.2024-10-02_19-51-37.tar no no '*' no no no
3 Likes

To achieve that you have two possibilities, if you do not want to restore the user entirely.

Manually make a zip/tar file of the following:

/home/username/mail/domain.com

After untarring or unzipping in the same place, it will only bring the newly arrived emails under the domain.com directory.

But this will only bring in the contents of all the directories under the domain.com. It will not recreate config files, which Hestia scripts will do.

So this is only an option, if all the configuration of the mail domain and mailboxes are configured and you did not change it.

Create a backup of that user and have it in your home computer.

Upload this backup to the newly restored VPS in its older version somewhere under /backup/temp.

Then, untar that backup file. This will open the tar and have /mail directory. Inside this, you will find one more tar compressed archive. This is the entire mail/domain.com mentioned above.

You can have this and unpack it plus update the directories, as mentioned in the above point one.

1 Like