首页 > Linux系统管理 > gitlab 备份恢复
2015
12-29

gitlab 备份恢复

备份路径在

vim /home/git/gitlab/config/gitlab.yml
 
  ## Backup settings
  backup:
    path: "/mnt/back/backups"   # Relative paths are relative to Rails.root (default: tmp/backups/)
 
默认是tmp/backups/ 我改了下目录
 
cd /home/git/gitlab
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production
Warning 
  You are running as user root, we hope you know what you are doing.
  Things may work/fail for the wrong reasons.
  For correct results you should run this as user git.
 
Dumping database ... 
Dumping MySQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
 * DSP/TLDsp ... [DONE]
 * DSP/TLDsp.wiki ...  [SKIPPED]
 * DSP/ControlCenter ... [DONE]
 * DSP/ControlCenter.wiki ...  [SKIPPED]
 * DSP/CookieMapping ... [DONE]
 * DSP/CookieMapping.wiki ...  [SKIPPED]
done
Dumping uploads ... 
done
Creating backup archive: 1451356575_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
Deleting old backups ... skipping

就已经备份好了
加到crontab 上去

# crontab -u git -l
0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

### 利用备份文件恢复

bundle exec rake gitlab:backup:restore RAILS_ENV=production 
```
 
选项:
 
``` 
BACKUP=timestamp_of_backup (required if more than one backup exists) 
```
 
类似这样:
 
``` 
Unpacking backup... [DONE] 
Restoring database tables: 
-- create_table("events", {:force=>true}) 
-> 0.2231s 
[...] 
- Loading fixture events...[DONE] 
- Loading fixture issues...[DONE] 
- Loading fixture keys...[SKIPPING] 
- Loading fixture merge_requests...[DONE] 
- Loading fixture milestones...[DONE] 
- Loading fixture namespaces...[DONE] 
- Loading fixture notes...[DONE] 
- Loading fixture projects...[DONE] 
- Loading fixture protected_branches...[SKIPPING] 
- Loading fixture schema_migrations...[DONE] 
- Loading fixture services...[SKIPPING] 
- Loading fixture snippets...[SKIPPING] 
- Loading fixture taggings...[SKIPPING] 
- Loading fixture tags...[SKIPPING] 
- Loading fixture users...[DONE] 
- Loading fixture users_projects...[DONE] 
- Loading fixture web_hooks...[SKIPPING] 
- Loading fixture wikis...[SKIPPING] 
Restoring repositories: 
- Restoring repository abcd... [DONE] 
Deleting tmp directories...[DONE]

如果备份的目录下不止一个备份文件,则RAILS_ENV=production后面需要指定备份文件 BACKUP=xxx。
至此备份恢复完毕。

最后编辑:
作者:saunix
大型互联网公司linux系统运维攻城狮,专门担当消防员

留下一个回复