日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux如何创建备份文件,如何备份Linux 配置文件

發布時間:2023/12/10 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux如何创建备份文件,如何备份Linux 配置文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如何備份Linux配置文件

文件備份是服務器安全最重要的一個環節,下面小編介紹使用Git工具來備份Linux配置文件。

一、安裝Git

[root@localhost ~]# yum install git

檢查Git版本

[root@localhost ~]# git --version

git version 1.8.3.1

[root@localhost ~]#

設置初始參數

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

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

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

二、現在初始化Git數據庫

因為我準備備份網絡配置文件,所以我只需要在網絡配置文件的目錄初始化Git數據庫。

[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” 文件夾被創建了。

三、使用下面的命令進行備份

[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]#

當我們執行第二個命令的時候,它會要求你輸入像 “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數據庫恢復網絡配置文件

[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 也不同。

驗證從 git 數據庫恢復的文件是否正確。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的linux如何创建备份文件,如何备份Linux 配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。