Skip to content
Snippets Groups Projects
Commit 94c9876a authored by Rutger Wessels's avatar Rutger Wessels
Browse files

Remove bash scripts

These scripts will be added to Omnibus.
parent 79d7edca
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !135585. Comments created here will be created in the context of that merge request.
#!/usr/bin/env bash
function generate_gitlab_config() {
gitlab_config="gitlab_rails['env'] = { 'GITLAB_ALLOW_SEPARATE_CI_DATABASE' => 'true' }
gitlab_rails['databases']['ci']['enable'] = true
gitlab_rails['databases']['ci']['db_database'] = 'gitlabhq_production_ci'"
if [ $GITLAB_BACKUP_CI_PGUSER ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_username']= '"$GITLAB_BACKUP_CI_PGUSER"'")
fi
if [ $GITLAB_BACKUP_CI_PGHOST ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_host']= '"$GITLAB_BACKUP_CI_PGHOST"'")
fi
if [ $GITLAB_BACKUP_CI_PGPORT ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_port']= '"$GITLAB_BACKUP_CI_PGPORT"'")
fi
if [ $GITLAB_BACKUP_CI_PGPASSWORD ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_password']= '"$GITLAB_BACKUP_CI_PGPASSWORD"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLMODE ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslmode']= '"$GITLAB_BACKUP_CI_PGSSLMODE"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLKEY ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslkey']= '"$GITLAB_BACKUP_CI_PGSSLKEY"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLCERT ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslcert']= '"$GITLAB_BACKUP_CI_PGSSLCERT"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLROOTCERT ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslrootcert']= '"$GITLAB_BACKUP_CI_PGSSLROOTCERT"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLCRL ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslcrl']= '"$GITLAB_BACKUP_CI_PGSSLCRL"'")
fi
if [ $GITLAB_BACKUP_CI_PGSSLCOMPRESSION ]
then
gitlab_config=$(printf "${gitlab_config}\ngitlab_rails['databases']['ci']['db_sslcompression']= '"$GITLAB_BACKUP_CI_PGSSLCOMPRESSION"'")
fi
echo "$gitlab_config"
}
if [ "$(id -u)" -ne 0 ]
then
echo "Please run as root." >&2
exit 1
fi
cat <<- EXPLANATION
This script will switch this GitLab instance from a single-database setup to
decomposed setup. When the script is finished, the database setup will look like this:
- main database: will still use PostgreSQL database 'gitlabhq_production'
- ci database: CI related data will be stored in PostgreSQL database 'gitlabhq_production_ci'
Prerequisites:
- The new ci database should already exist:
sudo gitlab-psql -c "CREATE DATABASE gitlabhq_production_ci WITH OWNER 'gitlab'"
What this script will do:
- Disable background migrations because they should not be active during this migration
See https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#enable-or-disable-background-migrations
- Stop the Gitlab Instance except PostgreSQL
- Copy data in gitlabhq_production to gitlabhq_production_ci (by dumping, then restoring)
Please confirm the upgrade by pressing 'y':
EXPLANATION
read -p "Are you sure? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo "Disabling Background migrations..."
gitlab-rails runner "Feature.disable(:execute_background_migrations) && Feature.disable(:execute_batched_migrations_on_schedule)"
echo "Stopping GitLab..."
gitlab-ctl stop
gitlab-ctl start postgresql
gitlab-rake gitlab:db:decomposition:migrate
if [ ! $? -eq 0 ]
then
echo "Could not copy database, exiting..."
exit 1
fi
cat <<- EOF
First step of migration is now done: data has been copied to new database.
You should now modify the GitLab configuration file in /etc/gitlab/gitlab.rb.
When you are ready, you can start the 'post-migrate' script.
EOF
generate_gitlab_config
#!/usr/bin/env bash
gitlab-ctl reconfigure
gitlab-rake gitlab:db:lock_writes
echo "Enabling Background migrations..."
gitlab-rails runner "Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)"
cat <<- EOF
GitLab is now running on two databases. Data related to CI is now written to the ci
database.
A copy of the original configuration file has been saved in /etc/gitlab/gitlab.rb.org
You can now start the GitLab services by running 'sudo gitlab-ctl restart'
You can also remove duplicated data by running:
'sudo gitlab-rake gitlab:db:truncate_legacy_tables:main'
'sudo gitlab-rake gitlab:db:truncate_legacy_tables:ci'
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment