日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
通過GIt備份Linux文件

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

創(chuàng)新互聯(lián)建站專注于瓊海網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供瓊海營銷型網(wǎng)站建設(shè),瓊海網(wǎng)站制作、瓊海網(wǎng)頁設(shè)計(jì)、瓊海網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)公司服務(wù),打造瓊海網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供瓊海網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

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

一、安裝 Git

[root@localhost ~]# yum install git

檢查Git版本

[root@localhost ~]# git --version  
git version 1.8.3.1  
[root@localhost ~]#

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

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

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

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

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

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

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

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

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

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

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

[root@localhost network-scripts]# git log  
commit 1269758e5f5b2fa3e0ad1fe507abaf73b646a33d  
Author: Pradeep 
  
    Date: Mon Oct 26 00:03:08 2015 -0400   Changes on 26 Oct 2015   [root@localhost network-scripts]
   # 
  

注意:嘗試在 “ifcfg-enp0s3” 文件中插入一些無用字符。

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

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

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

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


分享題目:通過GIt備份Linux文件
當(dāng)前路徑:http://m.5511xx.com/article/dhsjpge.html