Doing Backups 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/make_backup.sh
#!/bin/sh
tar -cvzf /backups/www.tar.gz /var/www

[root@serversuit ~]# nano /backups/make_backup.sh
[root@serversuit ~]# chmod +x /backups/make_backup.sh
[root@serversuit ~]# /backups/make_backup.sh
[root@serversuit ~]# ls /backups/ -g –h
-rwxr-xr-x 1 root   49 May 13 15:16 make_backup.sh
-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/make_backup.sh
#!/bin/sh
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/make_backup.sh

This will run a script ‘make_backup.sh’ 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!

This article was originally published in May 2016.

July 08 2020

Add or review comments

Please leave your comment

Existing comments

Comments 22


Sahil
The article is really good and has lots of knowledge, I wish to read more new article as I find it much beneficial.
Mohitvermaji51
this is really good information...thank you for sharing with us...
LarryUT
[url=http://j-pussy.com/]free tranny porn videos[/url]
FZMichael
[url=http://j-pussy.com/]free hispanic porn videos[/url]
vfEneda
cialis bulas med <a href="https://pcialis.com/">tadalafil cost walmart</a> cialis nitrostat
AeZew
consecuencias pastilla cialis <a href="https://cialidl.com/">much does cialis cost without insurance</a> dividere pillola cialis
BuDip
cialis name meaning <a href="https://cialnt.com/">how much does cialis cost without insurance</a> cialis pompelmo
NoBic
cialis efficacy for bph <a href="https://caciali.com/">cialis generika genauso gut</a> cialis pharmacie nice
DioBic
cialis generika 5g <a href="https://cialusorg.com/">prices for cialis in canada</a> lilly cialis fiyat
loans_On
payday loans online lakewood <a href="https://loanspersonala.com/">cash advances online dothan</a> no fax payday loans plano
ret_ken
We accept BitCoin - <a href="https://creamretin.com/">retin a shortage in canada</a> nombre generico cialis
ret_ken
We accept BitCoin - <a href="https://creamretin.com/">tretinoin gel buy</a> cialis docmorris
ret_ken
We accept BitCoin - <a href="https://creamretin.com/">isotretinoin online no prescription</a> cialis 5 mg contraindicaciones
loansGek
payday loans round rock tx <a href="https://onlinequickloans.us.org/">Payday Loans Stock</a> , <a href="http://cashadvanceonliner.com/">cash advanced in indio</a> cash advance america columbus
loansGek
advance cash faxing no <a href="https://onlinequickloans.us.org/">Payday Loans Wauseon</a> , <a href="http://cashadvanceonliner.com/">cash advance stores in pickerington ohio</a> merchant cash advance manhattan beach
DidHoazy
billig viagra cialis <a href="https://focialisaf.com/">brand cialis no prescription</a> generic cialis in bangkok
DidHoazy
cialis urinary frequency <a href="https://focialisaf.com/">generic cialis pharmacy</a> is generic cialis real
DidHoazy
cialis objednavka <a href="https://focialisaf.com/">does generic cialis exist</a> liquid cialis results
DidHoazy
what makes cialis more effective <a href="https://focialisaf.com/">cheap generic cialis online</a> cialis purchases
Fibek
<a href="https://uscialisuk.com/">brand cialis for sale</a> does cialis cause rapid heart beat <a href="https://bmzcialis.com">brand cialis 100mg</a> / <a href="https://cialics.com/">erectile dysfunction cialis</a>
Fibek
<a href="https://uscialisuk.com/">order cialis without a prescription</a> does cialis have enteric coating <a href="https://bmzcialis.com">cialis usa</a> / <a href="https://cialics.com/">how long does cialis 20mg last</a>
RobertBak
grand ages medieval cheat enginedell xps gen 3microsoft 12 days of deals leakdarksiders 2 deathinitive edition trainerricoh aficio sp 6330nasus wireless lan carddark souls prepare to die edition white screenfishing bot for wowyoga pro 3 windows 10what is nti backup [url=http://seominds.ru/tag/Цели/]samsung se-506cb driver [/url] [url=http://grabr.ru/tegi/biznes-v-seti-internet/]adblink device unauthorized fire tv [/url] [url=http://www.grabr.ru/tegi/chto-znachit-spam/]qualcomm atheros ar5bwb222 connectivity problems [/url] [url=http://besttops2n.blogspot.com/2021/04/mouse-with-pocket-scales.html]gta v ps3 to ps4 transfer [/url] [url=http://mybestnewss.blogspot.com/2021/05/freehand-software-free-download-for.html]turbo mailer 2.7 10 [/url] [url=http://seominds.ru/my/ryabova68/]verizon black friday 2016 deals [/url] [url=http://secondtops.blogspot.com/2021/04/automize-909-task-automation.html]magic lantern canon 60d [/url] [url=http://seominds.ru/tag/интерактивная школа/]fallout 4 preset mods [/url] [url=http://www.grabr.ru/tegi/baza-podpischikov/]integra dtr 30.7 reviews [/url] [url=http://grabr.ru/tegi/borba-s-lenyu/]rog strix b350-f gaming drivers [/url] songwriter's pad free download mac mini audio out farming simulator 17 save game editor year beast brawl dota 2 logitech hd pro webcam c910 software https://bobrdobr.ru/tags/public/характер+холерика/ https://bobrdobr.ru/people/annaryabova/ http://grabr.ru/tegi/kak-zarabatyvat-novichku-v-inter/ https://ukirilla.ru/neobkhodimoe-kachestvo-lidera-kotoroe-priblizit-vas-k-uspekhu-v-2011/ http://grabr.ru/tegi/uspeshnyi-internet-biznes/ http://www.grabr.ru/content/robin-sharma-26-prostykh-pravil-zametki-po-puti-v-rim/ http://grabr.ru/content/metody-povysheniya-motivatsii/ http://seominds.ru/my/ryabova68/ http://grabr.ru/tegi/liderskie-kachestva/ http://www.grabr.ru/tegi/kak-borotsya-s-lenyu/ creative zen touch 2 amd radeon hd 8250 polaroid snap firmware update dap-1320 firmware hp pavillion dv7 drivers dan aykroyd webbed toes ben 10 savage pursuit game anvi smart defender review fallout 4 lonesome rhode dlc release date playstation tv usb storage mahjong garden to go full version usb-bt400 driver windows 10 fallout new vegas card deck dell dimension xps gen 4 marta fifa 16 rating