CentOS backup HELP

RiaanRMC

Active Member
Joined
Apr 6, 2013
Messages
32
Reaction score
0
Good Day

I am in need of either a way to backup an running CentOS server or an script that will reboot to init 1 do a tar and reboot back to init 3.
For some reason i can not get my server to init 1 , it just respawns all the services again. i have written an cron job that change the default init level to 1 and reboots .Then i tried to add an startup script for init level 1 that will do the tar and reboot back to init 3 , so i get my server to init 1 with an cron job but then either i can not get my bash script to execute correctly , with my limited knowledge i ahve written the script as if i am typing the command manually on SSH, line 1 works line 2 works and then with the tar operation something goes wrong and while this is all happening behind the curtain when i log back in all the dam services is running again without executing my last script line teling the server to reboot to init 3

Drives me mad and i have to SSH now every week to make an manual backup.

If anybody can help me with this i will be very happy chappie
 
this an GUI for Rsync , i need an SSH text based solution , also Rsync does not backup files that are actively working , thus my current solution is to go to init 1 with edit enad reboot because init 1 wont stick when entered in init level 3
 
Rsync+Rdiff for backup.

Post your bash script here so we can see it.
 
Last edited:
I am in bed now will post the script tomorrow , did some reading up on rdiff and it just may be my solution , my greatest fear is live database files not getting backed up correctly and this will spell big horror for me, i have used the tar option and could boot up directly from the restored tar, minus the domain IP change.
Thanks so far i will give it an try
 
Linux sysadmins never go to bed this early. :eek:

They are always scouring the internet for more info.
 
LOL

I need to move my centos server over. Played with rsync, taring, the sorts.. no luck to "image" it over yet. Any tips would be helpful as I don't wanna have to go reset it all up.
 
I am in need of either a way to backup an running CentOS server or an script that will reboot to init 1 do a tar and reboot back to init 3.

Sending it to runlevel one sends kill - HUP to all running processes except init, so your script will be nuked.

A better way to do this (while staying while the big-tarball-of-the-server idea) is to take an LVM snapshot, and back that up. This may require you to do a few things to ensure consistent data, depending on what software you're running. For example, if you're running MySQL, you need to issue a "FLUSH TABLES WITH READ LOCK", do your snapshot, and then "UNLOCK TABLES".

A better way to do it is to back up your data with something dedicated to the type of data (i.e. mysqldump for MySQL backups), back up your configuration, and make sure you have a restore procedure documented and tested from time to time.
 
LOL

I need to move my centos server over. Played with rsync, taring, the sorts.. no luck to "image" it over yet. Any tips would be helpful as I don't wanna have to go reset it all up.
I used tar to move my server from uk vps to usa vps , and dropped in ontop of a running centos "with same version" changed the ip's and it worked first time
 
Linux sysadmins never go to bed this early. :eek:

They are always scouring the internet for more info.
The amount of sleep loss is mounting up to months now , and then you get one guy that have the solution and himself never needed it
 
I am in bed now will post the script tomorrow , did some reading up on rdiff and it just may be my solution , my greatest fear is live database files not getting backed up correctly and this will spell big horror for me, i have used the tar option and could boot up directly from the restored tar, minus the domain IP change.
Thanks so far i will give it an try

So write a script that makes a dump of it, and then restarts it. (if you can work like that). If you are using mysql its pretty easy to do.

I have a separate backup script for my mysql databases. If you cant stop the database long enough to do a mysql dump then you need to consider something on the enterprise level to deal with hot databases.
https://www.mysql.com/products/enterprise/backup.html
 
Last edited:
I am in need of either a way to backup an running CentOS server or an script that will reboot to init 1 do a tar and reboot back to init 3.

Sending it to runlevel one sends kill - HUP to all running processes except init, so your script will be nuked.

A better way to do this (while staying while the big-tarball-of-the-server idea) is to take an LVM snapshot, and back that up. This may require you to do a few things to ensure consistent data, depending on what software you're running. For example, if you're running MySQL, you need to issue a "FLUSH TABLES WITH READ LOCK", do your snapshot, and then "UNLOCK TABLES".

A better way to do it is to back up your data with something dedicated to the type of data (i.e. mysqldump for MySQL backups), back up your configuration, and make sure you have a restore procedure documented and tested from time to time.

I hear you , but my init command supose to set my server to level 1 then when view top it just respwans every single service without my help , if i can get it to stay in level 1 i wont need to reboot the thing at all
 
If you cant stop the database long enough to do a mysql dump then you need to consider something on the enterprise level to deal with hot databases.

You should never need to stop a database to do a backup. There are better ways to approach this. One would be to make sure you use the InnoDB storage engine for all your tables, and to mysqldump --single-transaction - this gives you a consistent snapshot of your data without taking your server down. Another way would be to set up a replication slave, and do your backups against it.

I hear you , but my init command supose to set my server to level 1 then when view top it just respwans every single service without my help , if i can get it to stay in level 1 i wont need to reboot the thing at all

Maybe I didn't use strong enough language before: You're doing it wrong! Step away from the server! You should never need to go to runlevel 1, unless your boot process is broken.
 
Get stuck in sorting out ICT issues like I did for two decades, neglected my body, cheated on my wife and children by remaining enslaved to MS Windows and its quirks. If I just had R1 for every time I saw it (re)boot........ The end result: diabetes, cardiovascular disease, stroke, hypertension. Medically retired before age 40. No IT system is worth your life. You have it but once. Live it.

I hope that someone learns from this. This thing of being a knight in armour who saves the day for a boss, a company or a client who is less loyal and committed, is misderected pride. Don't do it. Unless you can turn back time.
 
Last edited:
I am ''new'' to Linux but on MS the solution was to run a second server and backup from there, using a shadow backup tool. I cannot even recall what I had used - Tandberg, Blue Mountain, Macrium Reflect.....the list is endless and, as I have retired Jan 2000, memory is foggy. It really is good to have a **2nd server and backing up from there, hopefully off-site as well.** Linux must have tools for this. My rsync knowledge is in deficit.
 
If you can get budget for a backup solution, then look at:
ZManda
EMC Network

If you want to make your way work, then one solution would be to:
1) Create an additional partition that have a more minimal system on it.
2) Create a menu entry in /boot/grub/menu.lst for this partition. Call it something like "Backup Mode"
3) There is a script on the net called "grubonce", which allows you to boot into another boot menu once. Use this to boot to backup mode, run your backup with a startup script, and then reboot normally afterwards.

Another option:
Use "dd" over netcat to backup the whole disk image over the network. Just make sure to stop your application and database before doing it.
 
I am not an expert on linux , i have started about 7 months ago , and with google i have managed to build an fully working email server for me and all my family , it is running good now for 3 months , almost gave up hope sometimes with the unimaginal problems i got , all sorted now .
i have my var/mail going to a paid backup server every day about 5GB that updates only the newest files, i deleted the var/mail and restored it and all is good, then i ran out of memory and upgraded my server to 2 GB , i had to buy another server because my supplier could not just up the ram with my current 7$ special, this was done by targz to the new server and changeing the ip in some scripts , booted it up and by God it worked first time , so i am totally hooked on tar and i only need to reboot to init level 1 to get by backup done once a week MANUALLY .
But i can not get my stupid server to stay in level 1 to do the backup , if i view the services they will all die on giving the command and then when i have only 3 basic unkillable servases left it starts loading all the services again, even if i am considering a paid backup solution as specified above , i want my server to stay in level 1 because i am the boss and it should do as i say, i can not find any solution to keep it in level 1 on google exept for edit the inittab and manually type in "1" and reboot.
Man this drives me crazy
 
Get stuck in sorting out ICT issues like I did for two decades, neglected my body, cheated on my wife and children by remaining enslaved to MS Windows and its quirks. If I just had R1 for every time I saw it (re)boot........ The end result: diabetes, cardiovascular disease, stroke, hypertension. Medically retired before age 40. No IT system is worth your life. You have it but once. Live it.

I hope that someone learns from this. This thing of being a knight in armour who saves the day for a boss, a company or a client who is less loyal and committed, is misderected pride. Don't do it. Unless you can turn back time.

Best. Advice. Ever. :thumbup:
 
Best. Advice. Ever. :thumbup:
Agree but i keep pushing , i want a level where i can sit back and the dammn electronics do their own backups in my case , jeeslike i should of just found a farm worker job while i was still young and dumb
 
Top
Sign up to the MyBroadband newsletter
X