database migration from sqlite to postgres
Signed-off-by: philippe lhardy <philippe.lhardy@astrolabe.coop>
This commit is contained in:
@@ -59,4 +59,7 @@ et a activer l'application polls
|
||||
|
||||
# A Faire
|
||||
|
||||
utiliser la base de donnee postgres et non le SQLLite ?
|
||||
utiliser la base de donnee postgres et non le SQLLite ?
|
||||
|
||||
./migrate_db_sqlite2postgres.sh
|
||||
|
||||
|
||||
13
nextcloud_devenv/backup_sql.sh
Executable file
13
nextcloud_devenv/backup_sql.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
date
|
||||
|
||||
pg_dump=pg_dump
|
||||
|
||||
application=nextcloud
|
||||
BACKUP_ROOT_DIR=
|
||||
DATABASE=nextcloud_dev
|
||||
SQL_BACKUP_PATH="${BACKUP_ROOT_DIR}sql-${application}-$(date -Im).bak" && sudo -u postgres $pg_dump -p 5432 -F c $DATABASE | tee "$SQL_BACKUP_PATH" >/dev/null
|
||||
echo "$application postgres backup is in $SQL_BACKUP_PATH"
|
||||
|
||||
date
|
||||
15
nextcloud_devenv/config_db_query.sh
Normal file
15
nextcloud_devenv/config_db_query.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
query_password "database password :" password
|
||||
|
||||
if [[ -z $password ]]
|
||||
then
|
||||
log_error "Missing password"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
flavor=dev
|
||||
|
||||
database_name=nextcloud_$flavor
|
||||
username=nextcloud_$flavor
|
||||
db_port=5432
|
||||
db_hostname=127.0.0.1
|
||||
@@ -7,7 +7,29 @@ bind_folder=$(pwd)/$rel_bind_folder
|
||||
|
||||
timestamp=$(get_timestamp_second)
|
||||
|
||||
database_file=/data/owncloud.db
|
||||
database_dest=nextcloud.${timestamp}.db
|
||||
$defer sudo cp ${bind_folder}${database_file} ${database_dest}
|
||||
$defer sudo chown $(id -u):$(id -g) ${database_dest}
|
||||
getsqlite()
|
||||
{
|
||||
database_file=/data/owncloud.db
|
||||
database_dest=nextcloud.${timestamp}.db
|
||||
$defer sudo cp ${bind_folder}${database_file} ${database_dest}
|
||||
$defer sudo chown $(id -u):$(id -g) ${database_dest}
|
||||
}
|
||||
|
||||
getmysql()
|
||||
{
|
||||
BACKUP_FILE=nextcloud.${timestamp}.mysql
|
||||
database_dest=nextcloud.${timestamp}.db
|
||||
ssh ${SSH_URL} 'mysqldump -u adminmyweb -p nextcloud --single-transaction --quick --lock-tables=false' | cat > ${BACKUP_FILE}
|
||||
}
|
||||
|
||||
getpostgresql()
|
||||
{
|
||||
./backup_sql.sh
|
||||
}
|
||||
|
||||
|
||||
|
||||
log_warn "NO check if sqlite was migrated... so might get unused information"
|
||||
|
||||
getsqlite
|
||||
getpostgresql
|
||||
|
||||
24
nextcloud_devenv/migrate_db_sqlite2postgres.sh
Executable file
24
nextcloud_devenv/migrate_db_sqlite2postgres.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
source lib/metascript.sh
|
||||
|
||||
defaultmetainit $@
|
||||
|
||||
rel_bind_folder=bind_folder
|
||||
bind_folder=$(pwd)/$rel_bind_folder
|
||||
|
||||
$defer ./get_dbcontent.sh
|
||||
|
||||
# $defer ./setupdatabase.sh
|
||||
|
||||
log_info "See https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/db_conversion.html"
|
||||
|
||||
source ./config_db_query.sh
|
||||
|
||||
# convert localhost of host into container virtual brdige hostname mapping
|
||||
#db_hostname=host.docker.internal
|
||||
#db_hostname=host.containers.internal
|
||||
# host loopback mapped address
|
||||
db_hostname=10.1.1.13
|
||||
|
||||
$defer ./run_occ.sh db:convert-type --password="$password" --port="$db_port" --all-apps pgsql "$username" "$db_hostname" "$database_name"
|
||||
Reference in New Issue
Block a user