Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ GitLab remote backup of Linux Shell Scripting     - How to upgrade Docker 1.6 on Fedora / CentOS (Server)

- The three-way division of the sorting algorithm Quicksort (Programming)

- Let OS X support NTFS write file (Linux)

- Understand the security restore accidentally deleted critical system files (Linux)

- Linux system find command Detailed (Linux)

- Tsunami-udp accelerated network transmission (Linux)

- Hadoop 0.23 compile common errors (Server)

- CentOS 6.4 of cron scheduled task configuration (Linux)

- Virtual Judge environment to build and configure under Ubuntu (Server)

- Modify Linux SSH default port 22 in several ways (Linux)

- Windows 7 hard disk to install Ubuntu 14.10 (Linux)

- Installation and configuration of phpMyAdmin under CentOS (Database)

- Simple to use Linux GPG (Linux)

- C language programming entry - macro definitions and enum (Programming)

- APT-GET commonly used Linux command (Linux)

- ASP.NET 5 is connected with the Redis server on the Linux platform (Server)

- Installation Elementary OS Freya to do some settings (Linux)

- Bootable ISO image using GRUB (Linux)

- Fast Learning Clojure (Programming)

- 10 Codes of good practice PHP (Programming)

 
         
  GitLab remote backup of Linux Shell Scripting
     
  Add Date : 2018-11-21      
         
       
         
  NOTE: Gitlab Git is a service program, there are Web graphical interface and a series of management tools, specific details can Google it.

This one can be said to be "Atlassian confluence remote backup methods Linux Shell Scripting," the companion. Their description and principles are the same and the previous is that the core principles are core dump, scp, ssh and find + rm, but there are also different.

1.Gitlab itself provides a better backup method, only a simple command, and it also supports remote backup (remote storage and cloud storage), for example, it can be stored on the aws s3.

2. This script runs on Gitlab server, not on the backup server, on a script is running on the backup machine.

Script as follows:

#! / Bin / bash
# This shell script will execute on A Server
 
# SHELL = / bin / bash
# PATH = / sbin: / bin: / usr / sbin: / usr / bin
# MAILTO = root
# HOME = /
# For details see man 4 crontabs
# 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
# M h dom mon dow command
# Execute on 11:59 per sunday
# 59 11 * * * / 0 $ 0> / tmp / gitlab_backup _ $ (date -d "yesterday" + "% Y% m% d% H% M% S"). Log
# Execute on 23:59 per day
# 59 23 * * * $ 0> / tmp / gitlab_backup _ $ (date -d "yesterday" + "% Y% m% d% H% M% S"). Log
 
# Xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
# | Ssh tunnel |
# Xxx.xxx.xxx.xxx <==========> xxx.xxx.xxx.xxx
# | |
# ------- + ---------- + -----------------------------
# | |
# + + ----- + ----- + ------ + ------ +
# | A | | B |
# + + ------------- + ----------- +
# Gitlab server backups clinet
#
# A and B passed ssh Authentication
# A -> B: ssh lan_ip
# A -> B: ssh wan_ip
# B -> A: ssh lan_ip
# B -> A: ssh wan_ip
# A -> A: ssh lan_ip
# A -> A: ssh wan_ip
# B -> B: ssh lan_ip
# B -> B: ssh wan_ip
 
# Run as root, of course.
[$ UID -eq 0] || (echo "Must be root to run this script." && Exit 1)
save_days = 5
[$? -eq 1] && exit 1
gitlab_internal_backup_directory = / data / var / opt / gitlab / backups
# If you have both wan ip and lan ip, you can fill it with all, if you have one ip, you can fill it just with lan ip
backup_server_ipaddress_public = xxx.xxx.xxx.xxx
backup_server_ipaddress_private = xxx.xxx.xxx.xxx
# Select lan ip first for transmission speed
backup_server_hostname = $ {backup_server_ipaddress_private: - $ backup_server_ipaddress_public}
backup_server_ssh_username = root
#backup_server_ssh_port = $ (awk '/ Port / {print $ 2}' / etc / ssh / sshd_config)
backup_server_ssh_port = $ (netstat -anop | awk '/ sshd / && / LISTEN / {print $ 4}' | awk -F ':' '{print $ 2}')
backup_server_ssh_hostname = $ backup_server_hostname
backup_path = / data / gitlab_backup_directory
backup_path_time_uniq = $ (date -d "yesterday" + "% Y% m% d")
[-d $ Backup_path / $ backup_path_time_uniq] || mkdir -p $ backup_path / $ backup_path_time_uniq
# Sudo -u gitlab_ci -H bundle exec rake backup: create RAILS_ENV = production
echo "GitLab is executing backup operation, please hold on!"
/ Data / opt / gitlab / bin / gitlab-rake gitlab: backup:. Create> $ backup_path / $ backup_path_time_uniq / $ (date -d "yesterday" + "% Y% m% d") log 2> & 1
[? $ -ne 0] && echo "Local backup failed!" && Exit 1; echo "Local backup successfully!"
backuped_tar_file = `awk '/gitlab_backup.tar/ {print $ 4}' $ backup_path / backup_path_time_uniq / $ (date -d" yesterday "+"% Y% m% d "). log`
[-f $ Gitlab_internal_backup_directory / $ backuped_tar_file] && echo "Find backuped tar file successfully!"
ssh $ backup_server_ssh_username @ $ backup_server_ssh_hostname [-d $ backup_path / $ backup_path_time_uniq] || mkdir -p $ backup_path / $ backup_path_time_uniq
[? $ -ne 0] && echo "Remote backup directory creation failed!" && Exit 1; echo "Remote backup directory creation successfully!"
scp -P $ port $ gitlab_internal_backup_directory / $ backuped_tar_file $ backup_server_ssh_username @ $ backup_server_ssh_hostname: $ backup_path / $ backup_path_time_uniq
[? $ -ne 0] && echo "Remote backup transmission failed!" && Exit 1; echo "Remote backup transmission successfully!"
find $ gitlab_internal_backup_directory -mtime + $ save_days -exec rm -rf {} \;
[? $ -ne 0] && echo "Local expired backup remove skipped!"; Echo "Local expired backup remove successfully!"
find $ backup_path -mtime + $ save_days -exec rm -rf {} \;
[? $ -ne 0] && echo "Local expired tempdir remove skipped!"; Echo "Local expired tempdir remove successfully!"
ssh $ backup_server_ssh_username @ $ backup_server_ssh_hostname find $ backup_path -mtime + $ save_days -exec rm -rf {} \;
[? $ -ne 0] && echo "Remote expired backup remove skipped!"; Echo "Remote expired backup remove successfully!"
     
         
       
         
  More:      
 
- Oracle Data Pump Example (Database)
- Oracle GoldenGate encryption (Database)
- Open SSH remote access service that allows Android phone Ubuntu 14.04 (Linux)
- Linux loopback adapter Driven Design (Programming)
- Install Rubinius testing Ubuntu 14.04 native threads (Linux)
- Linux performance monitoring (Linux)
- Vim configuration instructions (Linux)
- httpd-2.4 feature (Server)
- Understand the security restore accidentally deleted critical system files (Linux)
- Thinking in Java study notes - Access modifiers (Programming)
- SLF4J Tutorial (Programming)
- Depth understanding of C language (Programming)
- Nginx Performance Tuning Guidelines (Server)
- Selection sort, insertion sort, and Shell sort (Programming)
- Samba public folder permissions (Server)
- JSON data normalization (normalize) (Programming)
- Let the terminal under Mac OS X as like Linux has displayed a variety of colors (Linux)
- Nginx Beginner Guide (Server)
- React Getting Started Tutorial (Linux)
- HTML5 Application Cache (Programming)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.