自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

你需要學(xué)會(huì)使用Git備份Linux配置文件

系統(tǒng) Linux 系統(tǒng)運(yùn)維
我們使用Linux服務(wù)器時(shí),有時(shí)候需要備份配置文件。如果我們使用Git,可以很輕松的管理配置文件的備份。在這篇文章中,我將會(huì)演示如何使用Git來(lái)實(shí)現(xiàn)備份以及管理備份。

  我們使用 Linux 服務(wù)器時(shí),有時(shí)候需要備份配置文件。傳統(tǒng)的備份方法是復(fù)制文件,改名,并在文件結(jié)尾插入一些字符。

[[155190]]

  但是,如果我們使用 Git ,我們可以很輕松的管理配置文件的備份。在這篇文章中,我將會(huì)演示如何使用 Git 來(lái)實(shí)現(xiàn)備份以及管理備份。我測(cè)試所用的環(huán)境是 CentOS 7 和 RHEL 7。

  一、安裝 Git  

  1. [root@localhost ~]# yum install git 

  檢查Git版本

 

  1. [root@localhost ~]# git --version  
  2. git version 1.8.3.1  
  3. [root@localhost ~]# 

  設(shè)置初始參數(shù)

  將如下命令中的用戶名,郵件替換成你自己的。

 

  1. [root@localhost network-scripts]# git config --global user.name "your_user_name" 
  2. [root@localhost network-scripts]# git config --global user.email "your_email" 

  二、現(xiàn)在初始化 Git 數(shù)據(jù)庫(kù)

  因?yàn)槲覝?zhǔn)備備份網(wǎng)絡(luò)配置文件,所以我只需要在網(wǎng)絡(luò)配置文件的目錄初始化Git數(shù)據(jù)庫(kù)。

 

  1. [root@localhost ~]# cd /etc/sysconfig/network-scripts  
  2. [root@localhost network-scripts]# git init  
  3. Initialized empty Git repository in /etc/sysconfig/network-scripts/.git/  
  4. [root@localhost network-scripts]# 

  命令行輸入 ls -a , 那么我們可以看到,“.git” 文件夾被創(chuàng)建了。

  三、使用下面的命令進(jìn)行備份

 

  1. [root@localhost network-scripts]# git add ifcfg-enp0s3  
  2. [root@localhost network-scripts]#  
  3. [root@localhost network-scripts]# git commit ifcfg-enp0s3  
  4. [master (root-commit) 1269758] Changes on 26 Oct 2015  
  5. 1 file changed, 16 insertions(+)  
  6. create mode 100644 ifcfg-enp0s3  
  7. [root@localhost network-scripts]# 

  當(dāng)我們執(zhí)行第二個(gè)命令的時(shí)候,它會(huì)要求你輸入像 “Changes on 26 Oct 2015” 這樣的備注,然后保存文件。

  使用下面的命令查看 git 日志

 

  1. [root@localhost network-scripts]# git log  
  2. commit 1269758e5f5b2fa3e0ad1fe507abaf73b646a33d  
  3. Author: Pradeep <pradeep@linuxtechi.com> Date: Mon Oct 26 00:03:08 2015 -0400  
  4. Changes on 26 Oct 2015  
  5. [root@localhost network-scripts]# 

  注意:嘗試在 “ifcfg-enp0s3” 文件中插入一些無(wú)用字符?! ?/p>

  四、從 Git 數(shù)據(jù)庫(kù)恢復(fù)網(wǎng)絡(luò)配置文件

 

  1. [root@localhost network-scripts]# git reset --hard 1269758e5f5b2fa3e0ad1fe507abaf73b646a33d  
  2. HEAD is now at 1269758 Changes on 26 Oct 2015  
  3. [root@localhost network-scripts]# 

  使用與上邊相同的 git id,你安裝的不同,git 的 id 也不同。

  驗(yàn)證從 git 數(shù)據(jù)庫(kù)恢復(fù)的文件是否正確。

  原文鏈接:http://www.linuxtechi.com/use-git-backup-configuration-files-on-linux/

責(zé)任編輯:火鳳凰 來(lái)源: Linux Story
相關(guān)推薦

2009-11-05 15:25:36

WCF服務(wù)端配置

2021-05-12 07:50:05

Linux運(yùn)維Linux系統(tǒng)

2013-12-19 09:20:59

2022-09-13 12:10:04

unlink刪除文件

2011-01-13 16:27:26

Linux配置文件

2023-10-30 07:05:31

2024-03-14 08:05:30

2021-07-28 08:53:53

GoGDB調(diào)試

2021-10-09 10:50:30

JavaScript編程開發(fā)

2020-04-09 10:49:19

VMware主機(jī)配置

2024-03-19 00:10:00

aiofilesPython開發(fā)

2022-06-12 16:05:22

vimLinux

2021-05-30 07:56:51

QSettingsLog4Qt變量

2010-06-17 21:34:05

2010-02-02 18:19:52

Linux mplay

2021-04-01 10:23:45

SpringBootbootstrapapplication

2009-08-18 10:56:40

Linux網(wǎng)卡配置Linux網(wǎng)卡配置

2021-12-28 07:20:43

Hippo WebAssembly云原生

2023-12-27 07:40:43

HTTP服務(wù)器負(fù)載均衡

2010-08-04 13:59:41

路由器配置
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)