How to backup root server with online shop

how can I backup my entire root server (UBUNTU 16)? It is hosted at MITTWALD. It is installed and configured (MAGENTO shop), now I want to backup the whole server with the possibility to restore it easily. I am not sure what is the best way to do this and I hope to get some good ideas.
Info: From the hosters console it is not possible to create backups.

Thank you!
Rio ReiserAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Simple way is to dump your database...

cd /your-site-docroot
mysqldump --defaults-file=/etc/mysql/debian.cnf --default-character-set=utf8 --opt --routines --triggers --events > db.sql

cd ..
zip -y -s -r -7 your-site-docroot

Open in new window

Then copy your files off your server each night.

I timestamp my backups for clients. If you're running pure Linux then use tar -Ipixz instead of zip.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rio ReiserAuthor Commented:
ahh thanks seems to be simple. Anyway:
- Do I use the "debian.cnf" also with UBUNTU?
- When zipping, do I also include permissions?
- How to restore the files?

I appreciate your help!
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Yes, use /etc/mysql/debian.cnf with Ubuntu.

Zip includes permissions + drops all ACLs/XATTRs, so if you use many complex ACLs, likely best to use tar -Ipixz instead of zip.

To restore, use unzip for .zip files + tar -xf for tar files.

You're welcome!
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Rio ReiserAuthor Commented:
Brilliant thank you David.
Just one question left: How do I best restore the database?

Thanks in advance!
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You're welcome.

To restore a database...

1) Create an empty database, remember to create correct GRANTs based on your database version (see your docs).

2) Then use your choice of load commands. I usually use pv, as I like to ensure I see the progress of a database load.

Using pv you can quickly see problems. For example, I once had a WordPress database using the Pretty Links plugin (shudder) + load time estimate was 40+ hours.

pv your.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 your-empty-database

Open in new window

Rio ReiserAuthor Commented:
Thank you David
Rio ReiserAuthor Commented:
Very helpful
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You're welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.