Removed backup, just database and user creation
This commit is contained in:
1 parent
de207176fe
commit
eeaff7a9fe
2 files changed
+1
-48
No files matched your search
@@ -16,7 +16,7 @@ docker run --rm \
|
|||||||
-e DB_DATABASE=database_to_create \
|
-e DB_DATABASE=database_to_create \
|
||||||
-e DB_USER=user_to_create \
|
-e DB_USER=user_to_create \
|
||||||
-e DB_PASSWORD=user_password \
|
-e DB_PASSWORD=user_password \
|
||||||
bboehmke/db-helper
|
dtwardow/db-helper
|
||||||
```
|
```
|
||||||
|
|
||||||
In compose file:
|
In compose file:
|
||||||
@@ -51,5 +51,4 @@ Available Configuration Parameters
|
|||||||
- **DB_DATABASE**: Database to create
|
- **DB_DATABASE**: Database to create
|
||||||
- **DB_USER**: User to create with access to `DB_DATABASE`
|
- **DB_USER**: User to create with access to `DB_DATABASE`
|
||||||
- **DB_PASSWORD**: Password of `DB_USER`
|
- **DB_PASSWORD**: Password of `DB_USER`
|
||||||
- **BACKUP_SCHEDULE**: If set an SQL dump of the database is created automatically all `15min`, `hourly`, `daily`, `weekly` or `monthly`
|
|
||||||
- **PG_EXTENSIONS**: List of postgres extensions (only for postgresql)
|
- **PG_EXTENSIONS**: List of postgres extensions (only for postgresql)
|
||||||
@@ -97,27 +97,6 @@ postgresql_init() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql_auto_backup() {
|
|
||||||
case ${BACKUP_SCHEDULE} in
|
|
||||||
15min|hourly|daily|weekly|monthly)
|
|
||||||
# create backup dir
|
|
||||||
mkdir -p /backup
|
|
||||||
|
|
||||||
# create backup script
|
|
||||||
cat > /etc/periodic/${BACKUP_SCHEDULE}/backup <<EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export PGPASSWORD=$DB_ROOT_PASSWORD
|
|
||||||
|
|
||||||
now=\$(date +"%Y%m%d_%H%M%S")
|
|
||||||
pg_dump -h ${DB_HOST} -p ${DB_PORT} -U ${DB_ROOT_USER} ${DB_DATABASE} | gzip -c > /backup/${DB_DATABASE}_\${now}.sql.gz
|
|
||||||
EOF
|
|
||||||
chmod +x /etc/periodic/${BACKUP_SCHEDULE}/backup
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mysql_clear_init() {
|
mysql_clear_init() {
|
||||||
result=`mysql -P $DB_PORT -u$DB_ROOT_USER -p$DB_ROOT_PASSWORD -h$DB_HOST -Bse "show databases like '$DB_DATABASE';"`
|
result=`mysql -P $DB_PORT -u$DB_ROOT_USER -p$DB_ROOT_PASSWORD -h$DB_HOST -Bse "show databases like '$DB_DATABASE';"`
|
||||||
if [ $result ]; then
|
if [ $result ]; then
|
||||||
@@ -148,25 +127,6 @@ mysql_init() {
|
|||||||
mysql -P $DB_PORT -u$DB_ROOT_USER -p$DB_ROOT_PASSWORD -h$DB_HOST -Bse "GRANT ALL PRIVILEGES ON \`$DB_DATABASE\`.* TO '$DB_USER'@'%';"
|
mysql -P $DB_PORT -u$DB_ROOT_USER -p$DB_ROOT_PASSWORD -h$DB_HOST -Bse "GRANT ALL PRIVILEGES ON \`$DB_DATABASE\`.* TO '$DB_USER'@'%';"
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_auto_backup() {
|
|
||||||
case ${BACKUP_SCHEDULE} in
|
|
||||||
15min|hourly|daily|weekly|monthly)
|
|
||||||
# create backup dir
|
|
||||||
mkdir -p /backup
|
|
||||||
|
|
||||||
# create backup script
|
|
||||||
cat > /etc/periodic/${BACKUP_SCHEDULE}/backup <<EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
now=\$(date +"%Y%m%d_%H%M%S")
|
|
||||||
mysqldump -h ${DB_HOST} -P ${DB_PORT} -u ${DB_ROOT_USER} -p$DB_ROOT_PASSWORD ${DB_DATABASE} | gzip -c > /backup/${DB_DATABASE}_\${now}.sql.gz
|
|
||||||
EOF
|
|
||||||
chmod +x /etc/periodic/${BACKUP_SCHEDULE}/backup
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
app:init|app:clear_init)
|
app:init|app:clear_init)
|
||||||
check_database_connection
|
check_database_connection
|
||||||
@@ -182,8 +142,6 @@ case ${1} in
|
|||||||
postgresql_clear_init
|
postgresql_clear_init
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
postgresql_auto_backup
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
mysql)
|
mysql)
|
||||||
@@ -196,12 +154,8 @@ case ${1} in
|
|||||||
mysql_clear_init
|
mysql_clear_init
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
mysql_auto_backup
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exec /usr/sbin/crond -f
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Reference in new issue
Block a user