Courseware: TAR project Actual case:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
[root@localhost ~]# yum -y install mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mkdir /backup
Example 1: Physical backup and restoration of mysql
[root@localhost ~]# tar -cJf /backup/mysql.tar.xz /var/lib/mysql
[root@localhost ~]# rm -rf /var/lib/mysql/*
[root@localhost ~]# tar -xf /backup/mysql.tar.xz -C /
Example 2: Physical backup and restoration of mysql
[root@localhost ~]# cd /var/lib/mysql
[root@localhost mysql]# tar -cJf /backup/mysql.tar.xz *
[root@localhost mysql]# tar -xf /backup/mysql.tar.xz -C /var/lib/mysql
Case 3: host A /etc ——–> host A/TMP
[root@localhost ~]# tar -czf etc.gz /etc -C /tmp
Case 4: host A /etc ——–> host B/TMP
General method:
[root@localhost ~]# SCP -r /etc 172.16.20.21:/ TMP
Suggested methods:
==host B’s listening port ==
[root@w_hat ~]# firewall-cmd –permanent –add-port=8888/tcp
[root@w_hat ~]# firewall-cmd –reload
or
[root@hostb ~]# systemctl stop firewalld.service
[root@hostb ~]# nc -l 8888 |tar -xzf – -C /tmp
==host A ==
/ root @ localhost ~ # tar – CZF – / etc | nc 172.16.20.21 8888
tar: Removing leading `/’ from member names
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =