linux git还原文件,Gitlab备份到windows、在Linux恢复
一 備份gitlab為完整壓縮包
# 在目錄/var/opt/gitlab/backups/ 創(chuàng)建備份文件
gitlab-rake gitlab:backup:create
/var/opt/gitlab/backups/
1559614181_2019_06_04_10.7.7_gitlab_backup.tar
查看備份文件夾容量
df -h /var/opt/gitlab/backups
二 恢復(fù)gitlab
復(fù)制gitlab_backup.tar到對(duì)應(yīng)備份目錄下
1 將備份文件權(quán)限修改為777
chmod 777 1559614181_2019_06_04_10.7.7_gitlab_backup.tar
2 停止相關(guān)數(shù)據(jù)連接服務(wù)
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
3 執(zhí)行命令從備份文件中恢復(fù)Gitlab
gitlab-rake gitlab:backup:restore BACKUP=備份文件編號(hào)
gitlab-rake gitlab:backup:restore BACKUP=1559614181_2019_06_04_10.7.7
輸入2次yes
4 啟動(dòng)Gitlab
sudo gitlab-ctl start
三 定時(shí)備份Linux文件到windows
1 設(shè)置定時(shí)備份
編輯文件 /etc/crontab 最后一行加入,記得加用戶名
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 2 * * 6 root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
每周六2點(diǎn),新備份文件會(huì)存于備份文件夾 /var/opt/gitlab/backups/
2 設(shè)置備份過(guò)期時(shí)間
設(shè)置只保存最近7天的備份,編輯 /etc/gitlab/gitlab.rb
gitlab_rails['backup_keep_time'] = 604800
sudo gitlab-ctl reconfigure
3 Windows下用sftp+腳本自動(dòng)下載Linux備份文件夾
3.1 windows安裝putty
在http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html下載putty工具包putty-64bit-0.71-installer.msi
,在win安裝,則cmd可運(yùn)行psftp.exe
3.2 建立psftp配置文件和下載腳本
在E:\85gitlab_backup創(chuàng)建2個(gè)文件:sftp.txt和gitlab_backup.bat
sftp.txt
lcd E:/85gitlab_backup
get -r /var/opt/gitlab/backups
bye
gitlab_backup.bat
@echo off
psftp 192.168.0.85 -l root -pw root -b "E:/85gitlab_backup/sftp.txt"
3.3 建立計(jì)劃任務(wù),定時(shí)運(yùn)行腳本
總結(jié)
以上是生活随笔為你收集整理的linux git还原文件,Gitlab备份到windows、在Linux恢复的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 用python生成云词汇_用python
- 下一篇: 中文python笔记_Python学习笔