In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
First, create backup files
First of all, we have to make an overall backup of the Gitlab on the old server. It is very easy to install Gitlab using the Gitlab one-click installation package, and the same backup recovery and migration is also very easy. A complete Gitlab backup can be created with a single command.
Gitlab full backup command:
Gitlab-rake gitlab:backup:create
Using the above command creates a zip file under the / var/opt/gitlab/backups directory named similar to 1545200330_2018_12_19_11.3.13_gitlab_backup.tar, which is the entire part of Gitlab, with the middle part being the 2018 December 19 issue created by the backup.
/ etc/gitlab/gitlab.rb configuration files must be backed up
/ var/opt/gitlab/nginx/conf nginx configuration file
After execution, the / var/opt/gitlab/backups directory creates a compressed package named similar to 1545201028_2018_12_19_11.3.13_gitlab_backup.tar
Change the Gitlab backup directory
You can modify the directory where the backup files are stored by default through the / etc/gitlab/gitlab.rb configuration file. The default backup path of the system is 229 in the configuration file. We only need to add a line below, or directly modify the default configuration and remove the comments.
After this step, you need to reload the configuration (equivalent to restarting gitlab) as follows:
Gitlab-ctl reconfigure
After that, we can do another full backup, and we can see that the backup directory has been changed by us.
Gitlab-rake gitlab:backup:create
III. Automatic backup of Gitlab
In the crontab file, each line represents a task, and each field on each line represents a setting. Its format is divided into six fields. The first five paragraphs are the time setting section, and the sixth paragraph is the command segment to be executed. Each field is separated by spaces, and the useless segments are replaced by *. The format is as follows:
Command
M h dom mon dow command
M: represents minutes and can be any integer from 0 to 59.
H: represents an hour and can be any integer from 0 to 23.
Dom: represents the date and can be any integer from 1 to 31.
Mon: represents the month and can be any integer from 1 to 12.
Week: represents the day of the week, which can be any integer from 0 to 7, where 0 or 7 represents Sunday.
Command: the command to be executed can be either a system command or a script file written by yourself (such as a shell file).
Make an automatic backup at 2 am every day: use the backup command through crontab, and restart the cron service.
# enter the command crontab-e
Crontab-e
# enter the appropriate task
0 2 * / opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
After editing, save and exit, you can also edit the vim / etc/crontab file directly, and the effect is the same. At this point, you need to restart the crontab service and set it to boot.
# restart the scheduled task service
Systemctl restart crond.service
# realize boot self-startup
Systemctl enable crond.service
4. Set the backup expiration time
Set to save only the backup for the last 7 days, edit the / etc/gitlab/gitlab.rb configuration file, find gitlab_rails ['backup_keep_time'], set it to the value you want to set, and save it. 604800 of this place is in seconds. Also reload the configuration after modification.
Restore gitlab from backup files
The first step is to change the permissions of the backup files to 777, otherwise there may be insufficient permissions and can not be decompressed during recovery.
Chmod 777 1545201028_2018_12_19_11.3.13_gitlab_backup.tar
Second, execute the command to stop the related data connection service.
Gitlab-ctl stop unicorn
Gitlab-ctl stop sidekiq
Third, execute the command to restore Gitlab from the backup file
The restore operation of Gitlab will empty all the current data first, and then restore based on the backup data.
# gitlab-rake gitlab:backup:restore BACKUP= backup file number
# for example, the number of our backup file is 1545202224, 2018 December 19,11.3.13, so you can restore it by executing the following command
Gitlab-rake gitlab:backup:restore BACKUP=1545202224_2018_12_19_11.3.13
After typing the command, the first interactive page appears
Enter "yes" to continue. It has already begun to recover.
The second interactive page appears and continue to enter "yes"
Step 4: start Gitlab
Gitlab-ctl start
Now that the data has been recovered, we can access the gitlab address http://192.168.10.178/dashboard/projects
Restore completed ~
GitLab reset username password
Open the terminal and visit:
Gitlab-rails console production
Enter:
User = User.where (id: 1) .first
User.password=123456
User.password_confirmation = '123456'
User.save! # pay attention to adding "!"
Then exit the command line.
Quit
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.