Create a full backup

Hello

What is the best method to backup IN v5?
When I take a backup of the .env file and a MySQL dump, do I then have everything to do a restore? Are eg. all the uploaded files stored in the database? Is something else stored on the file system?

Thank you

Hi,

@david where are the files stored?

documents /files are stored in public/storage

Okay great. So backing up the database, the .env file and the /public/storage folder should be enough. Am I correct?

Thanks

As an aside…

We take full cPanel backups daily of all the sites on our server, just in case.

Good idea.
I also take daily snapshots of my servers, but they are stored on the same physical location as the VM itself. So I also take my own backups and store them on 2 different locations. But to script that, I had to know what exactly what exactly needs to be backed up.

Hi @KrisL Was wondering if your backups are going ok? New to Linux here was trying to find out my self on what or how the best way to perform backups … When using scripts do you need to stop services for InvNinja, database, etc before making copies? or does it allow you to copy?

Hello

I have several bash scripts to create and store local back-ups of the database and the files, which I back-up again each night to another off-site location. The local back-ups are just the back-ups of the last two days and used for a quick restore. The off-site back-ups are stored several weeks and are encrypted.

To back-up the InvoiceNinja database, you can stop the application so it doesn’t write things to the database at the same time. But when you create the back-up at down hours, eg nightly, you can just run mysqldump. Eg:

mysqldump -h localhost -P 3306 name-of-your-db | gzip > /path/to/backup/location/$(date +%Y-%m-%d).sql.gz

Here is a good read: How To Import and Export Databases in MySQL or MariaDB | DigitalOcean

1 Like

Thank you!! I also found this: https://github.com/fredsimard/invoice_ninja_backup_bash_script

Hope the above will work out…

oh wow, this script is awesome!
would be great if the IN team could implement that to the app.

I would pay for this add on service!

Just a note,

In Settings > Import | Export

you can do a full json export, this is the same as exporting your DB.

1 Like

Hi David, can you tell me how to do that. If I did not set up the smtp email server in the env file? Cause when I want to export a JSON File I get the notification that an email with a link was send. Logically this email will never reach out to me. Any solution for that? Thanks a lot!!

If you’re transferring to a selfhost install it’s better to use mysqldump instead.

Okay, I‘ll give it a try. Thank you!

Is the json export a backup of the full database? (Meaning if I start a new instance of Invoice Ninja is that all I need?)

Second, is there a api call to trigger that export? (I did not find one in the doc’s)

If you transferring between self-host installs it’s better to use mysqldump to backup your DB, the JSON export is useful to transfer between hosted/self-hosted.