-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gitlab: add script to create fs and raid for backup partition
This change adds a script to configure the two additional SSDs to be used as backup partition for /srv/gitlab-backup. As mentioned in Ie77560b55076c94bec255f5577e2d75492496d08 we were unable to implement this in partman, so bootstrapping the backup partition was moved to a dedicated script. Bug: T330172 Bug: T333674 Change-Id: I8766182572f2a3da2916b85c7ec3226b60ba5119
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# File was created using sfdisk --dump on a properly configured disk. | ||
label: dos | ||
label-id: 0x94fe5067 | ||
unit: sectors | ||
sector-size: 512 | ||
start= 2048, size= 3750746800, type=fd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Provision filesystems and raid for GitLab backup volume | ||
# GitLab backups are stored on dedicated SSDs /dev/sdc and /dev/sdd | ||
# https://phabricator.wikimedia.org/T333674 | ||
|
||
RAID_NAME="/dev/md1" | ||
MOUNT_POINT="/srv/gitlab-backup" | ||
|
||
set -u | ||
set -x | ||
|
||
create_fs() { | ||
if [ ! -e $RAID_NAME ]; then | ||
sfdisk /dev/sdc < /opt/gitlab-backup-raid.cfg | ||
sfdisk /dev/sdd < /opt/gitlab-backup-raid.cfg | ||
|
||
mdadm --create $RAID_NAME --level=mirror --raid-devices=2 /dev/sdc1 /dev/sdd1 | ||
mkfs.ext4 $RAID_NAME | ||
else | ||
echo "Raid $RAID_NAME already exists, skipping creation" | ||
fi | ||
|
||
} | ||
|
||
mount_fs() { | ||
if [ ! -d "$MOUNT_POINT" ]; then | ||
mkdir $MOUNT_POINT | ||
else | ||
echo "Mountpoint $MOUNT_POINT already exists, skipping creation" | ||
fi | ||
|
||
if ! grep -q "^$RAID_NAME $MOUNT_POINT " /etc/fstab ; then | ||
echo "$RAID_NAME $MOUNT_POINT ext4 defaults 0 0" >> /etc/fstab | ||
else | ||
echo "fstab entry for $RAID_NAME at $MOUNT_POINT already exists, skipping creation" | ||
fi | ||
|
||
if ! findmnt $MOUNT_POINT; then | ||
mount $MOUNT_POINT | ||
else | ||
echo "$MOUNT_POINT already mounted, skipping mount" | ||
fi | ||
} | ||
|
||
create_fs | ||
mount_fs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters