К основному контенту

Как сделать бэкап всей системы в centos

Если вам нужно создать backup всей вашей системы, то необходимо выполнить команду:

# sudo tar cvpzf /my_backup.tgz —exclude=/proc —exclude=/lost+found —exclude=/backup.tgz —exclude=/mnt —exclude=/sys /
Этой команды хватит чтобы создать бекап. Поговорим о том что же в этой команде написано:
1.  Запускаем команду от рута и создадим так званый тарбол (утилита tar с опцией «c») и заархивируем его в архив gz (опция «z»). С опцией «—exclude» исключим из нашего архива все системные папки и файлы устройств и наш архив (чтобы он рекурсивно не начал запаковывать сам в себя). По окончанию, получим в корневой директории  наш cжатый архив системы в файле my_backup.tgz.
Бекап мы то сделали, но наверное нужно еще и научится разворачивать его.Как это сделать? Ну, для начала, нужна будет всё-таки работающая система. Можно выполнить установку системы или просто загрузиться с Live CD/DVD). Я, буду думать что у всех есть уже готовая установленная и готова к работе система на которой хотим сделать развертку нашего архив my_backup. Для этого необходимо выполнить команду:
# tar xvpfz /backup.tgz -C /
ВСЕ! ГОТОВО! На этом  тема «как сделать бэкап всей системы в centos» завершена.

Ok. The best way to go about this is using rsync. Install rsync on the VPS if it isn't already (probably is).

I am assuming that you have ssh server on the machine where you want the backup (your new VPS?) and that it is listening on the standard port 22.
On the machine where the backup will go, make a new directory called VPSbackup or whatever. Below you can see in the example I assume it is at /home/myuser/VPSbackup.
On your VPS, run:
 rsync -avz --exclude=/proc --exclude=/sys --exclude=/dev -e ssh / myuser@my_ip_address:/home/myuser/VPSbackup

                                        
1:
Select all
Open in new window

You will then type in the password for myuser when you are prompted, and the backup will begin. 
You can also do it in reverse, if you want to use rsync from the local machine (maybe you are behind NAT and/or don't have a public listening ssh server on the backup machine) like so:
rsync -avz --exclude=/proc --exclude=/sys --exclude=/dev -e ssh root@vps_ip_address:/ /home/myuser/VPSbackup

                                        
1:
Select all
Open in new window

In either case, be patient---it'll take a while :-)

To restore the backup to your new VPS, first install the same version of CentOS on the VPS (just a vanilla install with SSH server) and copy the backup on to it.
From the new VPS:
rsync -avz -e ssh myuser@my_ip_address:/home/myuser/VPSbackup/* /

                                        
1:
Select all
Open in new window

OR from the machine where the backup is:
rsync -avz -e ssh /home/myuser/VPSbackup/* root@new_vps_ip_address:/

                                        
1:
Select all
Open in new window


Note that doing it using rsync will copy all the files on your VPS to the VPSbackup directory on the backup machine. If you want everything is one big backup file, then you may want to use tar via ssh like so (on the VPS machine):
tar zcvf - --exclude=/proc --exclude=/sys --exclude=/dev  / | ssh myuser@backupmachine_ip_addr "cat > /home/myuser/VPSbackup.tar.gz" 

                                        
1:
Select all
Open in new window

Then to restore to the new VPS (run this on the new VPS):
cd /
ssh myuser@backupmachine_ip_addr "cat /home/myuser/VPSbackup.tar.gz" | tar zxvf - 

                                        

Комментарии

Популярные сообщения из этого блога

How to do Arithmetic Operations in Ansible

You can use arithmetic calculations in Ansible using the Jinja syntax. This is helpful in many situations where you have stored the output of an operation, and you need to manipulate that value. All usual operation like addition, subtraction, multiplication, division, and modulo are possible. Let us start with an example. We will be using the  debug module  to print the out the result. The following tasks show all the basic arithmetic operations. The output is given in comments. Ansible arithmetic operation example - hosts: loc tasks: - debug: msg: "addition{{ 4 +3 }}" #Ansible addition 7 - debug: msg: "substraction {{ 4 - 3 }}" #Ansible arithmetic substraction 1 - debug: msg: "multiplication {{ 4 * 3 }}" #multiplication 12 - debug: msg: "Modulo operation {{ 7 % 4}}" #ansible Modulo operation - find remainder 3 - debug: msg: "floating division {{ 4 / 3}}" #ansible floating divisio...

ubuntu/debian ipmi

#install ipmitool (this is for debian) apt-get install ipmitool #insert the kernel modules needed for ipmi modprobe ipmi_devintf modprobe ipmi_si modprobe ipmi_msghandler #get the current mode (01 00 is dedicated mode) ipmitool raw 0x30 0x70 0x0c 0 #send the raw command to enable dedicated lan ipmitool raw 0x30 0x70 0xc 1 1 0
Ansible - Appending to lists and dictionaries  n this blog post I'll show how to add items to lists and dictionaries, when using loops, and across tasks. Normally when trying to add a new item to the variable, while in the loop, or between tasks, Ansible will ovewrite the values, keeping the result of the last iteration. For example, let's see what will be the result of running the following playbook: --- - name: Append to list hosts: localhost vars: cisco: - CiscoRouter01 - CiscoRouter02 - CiscoRouter03 - CiscoSwitch01 arista: - AristaSwitch01 - AristaSwitch02 - AristaSwitch03 tasks: - name: Add Cisco and Airsta devices to the list set_fact: devices: "{{ item }}" with_items: - "{{ cisco }}" - "{{ arista }}" - name: Debug list debug: var: devices verbosity: 0 [przemek@quasar blog]$ ansible-playbook append_list.yml PLAY [Append to list] ****************...