ทำ Auto Backup GitLab ข้าม Server และ กำหนดให้เก็บไฟล์ไว้ตามระยะเวลาที่ต้องการ

แชร์ความรู้ Linux Ubuntu Web Server บทความ การ config server Linux FreeBSD Apache
การติดตั้ง XAMPP Mysql PHP ใครต้องการแชร์ความรู้เรื่องต่างๆ เหล่านี้ให้ ท่านหรืออื่น โพสที่หมวดนี้ได้

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41131
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

ทำ Auto Backup GitLab ข้าม Server และ กำหนดให้เก็บไฟล์ไว้ตามระยะเวลาที่ต้องการ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ทำ Auto Backup GitLab ข้าม Server และ กำหนดให้เก็บไฟล์ไว้ตามระยะเวลาที่ต้องการ
จากกระทู้ที่แล้ว
วิธี Backup Restore Gitlab remote Server ใช้ได้กับ OS เวอร์ชั่นต่างกัน

กระทู้นี้มาดูวิธีการ ทำ Auto Backup GitLab ข้าม Server กันบ้าง
ประโยชน์ คือ เราไม่ต้องเสียเวลานั่งทำ backup เอง และ Save ไฟล์ backup ไว้สอง ที่แบบ auto เพื่อถ้าเกิดปัยหา Server หนึ่งเสีย เราสามารถนำไฟล์ ที่ backup ไว้มา restore แล้วใช้งานต่อได้เลย

วิธีทำ จะใช้ scipt ไฟล์ .sh ช่วย สามารถโหลได้ที่ https://github.com/sund/auto-gitlab-backup
วิธี
1. แก้ไขไฟล์ /etc/gitlab/gitlab.rb เพื่อ กำหนด ระยะเวลาที่ต้องการเก็บไฟล์ backup ไว้

โค้ด: เลือกทั้งหมด

# backup keep time
gitlab_rails['backup_keep_time'] = 604800
2. โคลน หรือ โหลดไฟล์ auto-gitlab-backup ไปไว้ที่ /usr/local/sbin

โค้ด: เลือกทั้งหมด

git clone https://github.com/sund/auto-gitlab-backup.git
3. เข้าไปที่ Folder auto-gitlab-backup และ copy ไฟล์ config เพื่อปรับแต่งค่าตามต้องการ

โค้ด: เลือกทั้งหมด

cp auto-gitlab-backup.conf.sample auto-gitlab-backup.conf
แก้ไขไฟล์ auto-gitlab-backup.conf

4. ตั้งให้เครื่องทำงานอัตโนัต

โค้ด: เลือกทั้งหมด

crontab -e
เลือกโปรแกรมแก้ไขไฟล์ตามต้องการ แล้วใส่โค้ดด้านล่างนี้ลงไป

โค้ด: เลือกทั้งหมด

0 21 * * * /usr/local/sbin/auto-gitlab-backup/auto-gitlab-backup.sh 
**** ตามตัวอย่างจะทำงานทุก สามทุ่ม
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41131
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: ทำ Auto Backup GitLab ข้าม Server และ กำหนดให้เก็บไฟล์ไว้ตามระยะเวลาที่ต้องการ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ตัวอย่างไฟล์
auto-gitlab-backup.conf

โค้ด: เลือกทั้งหมด

# unless $localConfDir is outside /var/opt/gitlab/backups/configBackups
# you can leave this blank
remoteConfDest=""

## ssh port or 873 for rsyncd port
remotePort=1122

## git user home.
#  Only change the below setting if you have git's home in a different location
gitHome="/var/opt/gitlab"

## only set below if rvm is in use and you need to source the rvm env file
# echo $(rvm env --path)
RVM_envPath=""

## only use the below settings if your destination is using rsync in daemon mode
remoteModule=""
rsync_password_file=""

## localbackup directories
# only change if gitlab_rails['backup_path'] in gitlab.rb is set
# other than $gitHome/[backups|ci-backups]
gitRakeBackups="/var/opt/gitlab/backups"
gitRakeCIBackups="/var/opt/gitlab/ci-backups"

## only change if configs are in different locations. (unlikely)
localConfig="/etc/gitlab"
localsshkeys="/var/opt/gitlab/.ssh"

## Check remote quota
#  change to true or 1 to enable
checkQuota="0"

ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 33