Basics Of Setting Up A Backup On Linux

Every system administrator should know that server backups are necessary and they must be configured so soon as possible. One of the first things you're taught as an IT professional. And yet every day another unlucky soul ends up with corrupted or deleted data, because the server hanged or the hard disk broke and suddenly realized that they forgot to setup a backup. Sounds familiar? I hope not, but almost everyone ends up in that place, eventually. Lett's at least try not to repeat these mistakes.

So, today, let me show you the basics of setting up a backup on your Linux system. Let’s assume that you’ have a website on your server, and you want to have a backup copy on the same server somewhere, and you'll probably will want to send it to another computer, too. We’ll need to create a backup directory, and we'll use the following scripts:

[root@serversuit ~]# mkdir /backups
[root@serversuit ~]# nano /backups/
tar -cvzf /backups/www.tar.gz /var/www

[root@serversuit ~]# nano /backups/
[root@serversuit ~]# chmod +x /backups/
[root@serversuit ~]# /backups/
[root@serversuit ~]# ls /backups/ -g –h
-rwxr-xr-x 1 root   49 May 13 15:16
-rw-r--r-- 1 root 111M May 13 15:18 www.tar.gz

If we add this script to cron to run daily, you’ll always have the current site's HTML files backed up to the server's /backup directory. You can download it to another computer, too. What if your website is not just HTML or PHP files, but MySQL database files too?  There's a slightly altered script to do that as well:

[root@serversuit ~]# nano /backups/
tar -cvzf /backups/www.tar.gz /var/www
mysqldump –u root -pPASSWORD DATABASE > /backups/dump.sql

You’ll need to provide the root password and database name to make script work. Please be aware that your MySQL database backup can take a long time and significantly increase server load. That script can be used for relatively small databases, but it should probably be run overnight to avoid overloading your server. This is the script you'll need to add the backup to cron and run it overnight:

[root@serversuit ~]# crontab -e
0 3 * * *       /backups/

This will run a script ‘’ once a day at 3am, overwriting old backup files. It’s not too hard at all... just time consuming, especially in cases where you have multiple servers or websites.

But hey, that's why we built ServerSuit.

We can help with that too. We have a preconfigured backup tool you can easily setup on your servers with just a few clicks, and no coding requires. Use it to safely backup your domains, MySQL databases, and FTP folders. You can access your server backups through ServerSuit's browser dashboard. Try it out! ServerSuit is free for 30-days when you first sign up! Check us out!

Until next time!

May 14 2016

Add or review comments

Please leave your comment

Existing comments

Comments 5

gaurav kumar
not very valuable...
Are there really Linux guys, that can learn anything out of this?
Yes, they are :-)
Henris Kavaliauskas
very simple artical , you might want to consider RSYNC instead or in combo with what you developed , you title is misleading , you don't need to backup the SERVER it's the data and configuration files you need to backup , you can allways re install the server .
purchasing cialis online
beli kamagra malaysia haurrehigh [url=]cialis buy online[/url] Engeda Is Keflex A Type Of Penicillin Awagosoods <a href=>best place to buy cialis online</a> noinly Fluoxetin Online Bestellen Ohne Rezept