Help with a backup

Hi, I have installed a pritunl server (ver. enterprise) in which I have configured multiple servers. For security reasons I have created a script that uses crontab to make a backup copy of mongodb on a daily basis.

All this happens regularly but it often happens that I find the servers active but all the clients disconnected (or partially) as well as no longer being able to establish new connections and I am contracted to perform a stop & start of all the servers present via the web and only in this way does everything work again.

What can I add or change to my script so that this doesn’t happen again?

This is the content of the script:

sudo service pritunl stop
mongodump -d pritunl -o pritunl-bkp
tar -czvf pritunl-bkp.tar.gz pritunl-bkp

Thank you

The Pritunl service doesn’t need to be stopped to backup the database, that will disrupt connections. The file /var/lib/pritunl/pritunl.uuid should be included in the backup. This file is the host ID that identifies the host in a cluster.

In the meantime, thank you for answering me. can you give me an example of how to write the script with integration of this file?

In the last line of your script, include that file into the tar archive you create:

tar czvf pritunl-bkp.tar.gz pritunl-bkp /var/lib/pritunl/pritunl.uuid

OK thank you. but a curiosity what does this file contain?

The uuid file contains the host ID that identifies the host in the cluster. If an enterprise subscription is configured the hosts are shown in the web console. If the host ID is not restored a new host is created and it will need to be re-attached to the servers. If there is no enterprise subscription the single host will automatically attached to all servers.

perfect it’s clear but the thing I don’t understand is that this can be useful in the case of a backup restore but for me the problem occurs when the backup has just been performed.

anyway can you give me an example of how to integrate the file into the backup script?

Up please?

Where is a complete command for restore with “/var/lib/pritunl/pritunl.uuid” ?

No command needs to be run, it’s a file with an ID. The file needs to contain the ID and the server can be started with sudo systemctl start pritunl.

Yes ok but I was wondering when you run the command “tar czvf pritunl-bkp.tar.gz pritunl-bkp /var/lib/pritunl/pritunl.uuid” this uuid file is also put in the bkp.tar.gz or else (as indicated in the suggested line) will it be executed after the tar.gz has been created?

I’m not sure I understand. Why do you think the command I’ve posted will try to execute the UUID file?
That’s not how unix works. What we are doing here is just: ‘program arg1 arg2 arg3… argN’. So basically ‘tar’ is the program here, and everything else is passed as arguments to ‘tar’.

And now check out the manual page for tar. The syntax for creating archive allows specifying multiple paths to be included in the archive. And that’s what that command is doing. Yes, the uuid file will be the part of the archive.

Ok it’s clear now, so it will also be inserted into the tar.gz archive and will automatically return to its original position when it is decompressed.