This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
forked from pivotal-cf/docs-concourse-olm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbacking-up.html.md.erb
76 lines (59 loc) · 3.69 KB
/
backing-up.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
title: Backing Up and Restoring a Concourse OLM Database
owner: Concourse
---
Backing up Concourse OLM databases is a best practice that helps protect pipelines, build history, and team information over time. Pivotal recommends that you schedule periodic backups of your Concourse OLM database, before and after updates, or after other substantial changes.
You can also use backed up versions of databases to restore database states after unexpected problems, like database failure, corruption, or interference from malicious third parties. Specifically, the backup and restore process restores build history, pipelines, and team information. It cannot restore builds that were running at the time of backup.
A Concourse database is a PostgresSQL database that can be internal (deployed from the Concourse BOSH release) or external (configured with Concourse).
For complete backup and restore procedures refer to the documentation for your version of PostgresSQL database. For example: [https://www.postgresql.org/docs/9.1/static/backup.html](https://www.postgresql.org/docs/9.1/static/backup.html).
This topic provides a sample backup and restore procedure for an internal Concourse PostgresSQL database.
## Backing Up a Concourse OLM Database
This procedure explains how to back up a Concourse OLM database deployed from the Concourse BOSH release.
<ol>
<li>SSH into your database VM. You may want to use <a href="https://bosh.io/docs/sysadmin-commands.html#ssh">BOSH SSH</a>.</li>
<li>Open a terminal window.</li>
<li>Locate the Postgres binaries on your VM by entering the following command:<br/>
<pre class="terminal">
ps aux | grep postgres
</pre>
The binary location displays.
</li>
<li>Switch to the <code>vcap</code> user. This user has permissions to use the backup and restore commands.<br/>
<pre class="terminal">
sudo su vcap
</pre>
</li>
<li>Navigate to the root directory.<br/>
<pre class="terminal">
cd ~
</pre>
</li>
<li>Enter the command to generate a backup file:
<pre class="terminal">
POSTGRES-BINARY-LOCATION/pg_dumpall -c -f /FILEPATH/BACKUP-FILE-NAME
</pre>
When you generate the backup file, you can use any name and any file extension. For example: "january-backup.txt".
<p class="note"><strong>Note</strong>: The -c flag will wipe any unsaved data on the database. When you back up the database, check to be sure you have saved any important data.
</p>
</li>
<li>Extract the backup file from the VM. You may want to use <a href="https://bosh.io/docs/cli-v2.html#errand-mgmt">BOSH SCP</a>.</li>
<li>Store the backup file somewhere secure.</li>
</ol>
## Restoring a Concourse OLM Database
Once you generate a backup file, you can apply it to a database to restore a previous state. Do not use a backup file to overwrite an existing database. Overwriting databases leads to data loss, and may lead to total deployment failure. Only apply a backup to a new database.
Follow the steps below to restore a Concourse OLM database.
<ol>
<li>Insert your backup file into the database VM. You may want to use <a href="https://bosh.io/docs/cli-v2.html#errand-mgmt">BOSH SCP</a>.</li>
<li>SSH into your database VM. You may want to use <a href="https://bosh.io/docs/sysadmin-commands.html#ssh">BOSH SSH</a>.</li>
<li>Locate the Postgres binaries on your VM by entering the following command:<br/>
<pre class="terminal">ps aux | grep postgres</pre>
The binary location displays.
</li>
<li>Switch to the <code>vcap</code> user. This user has permissions to use the backup and restore commands.<br/>
<pre class="terminal">sudo su vcap</pre></li>
<li>Navigate to the root directory.<br/>
<pre class="terminal">cd ~</pre></li>
<li>
Apply the backup file to the database.
<pre class="terminal">psql -f BACKUP-FILE-NAME</pre></li>
</ol>