summaryrefslogtreecommitdiff
path: root/backup
diff options
context:
space:
mode:
authorLingxian Kong <anlin.kong@gmail.com>2020-09-08 23:03:34 +1200
committerLingxian Kong <anlin.kong@gmail.com>2020-09-11 13:48:32 +1200
commit5482c54645fcea2af6b61837e8ff78cd77e1810c (patch)
tree3f6d03006c6237ef9a4d864c6430aa6070394369 /backup
parent8761f327fe8e4fca55d8fd667f7b9cf279d29299 (diff)
downloadtrove-5482c54645fcea2af6b61837e8ff78cd77e1810c.tar.gz
[Postgresql] Create replica
Change-Id: Ia00032074dc44a6fbfc1e2d5ab16d1734a1a732c
Diffstat (limited to 'backup')
-rw-r--r--backup/Dockerfile2
-rw-r--r--backup/drivers/innobackupex.py4
-rw-r--r--backup/drivers/mysql_base.py3
-rwxr-xr-xbackup/install.sh8
4 files changed, 11 insertions, 6 deletions
diff --git a/backup/Dockerfile b/backup/Dockerfile
index 38ebb14a..a5e4e7e0 100644
--- a/backup/Dockerfile
+++ b/backup/Dockerfile
@@ -10,6 +10,7 @@ RUN export DEBIAN_FRONTEND="noninteractive" \
RUN apt-get update \
&& apt-get install $APTOPTS gnupg2 lsb-release apt-utils apt-transport-https ca-certificates software-properties-common curl \
+ && apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall netbase \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@@ -20,6 +21,7 @@ RUN ./install.sh $DATASTORE ${PERCONA_XTRABACKUP_VERSION}
RUN apt-get update \
&& apt-get install $APTOPTS build-essential python3-setuptools python3-all python3-all-dev python3-pip libffi-dev libssl-dev libxml2-dev libxslt1-dev libyaml-dev \
&& apt-get clean \
+ && rm -rf /var/lib/apt/lists/* \
&& pip3 --no-cache-dir install -U -r requirements.txt \
&& curl -sSL https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -o /usr/local/bin/dumb-init \
&& chmod +x /usr/local/bin/dumb-init
diff --git a/backup/drivers/innobackupex.py b/backup/drivers/innobackupex.py
index 9bbebc3a..ff5446c7 100644
--- a/backup/drivers/innobackupex.py
+++ b/backup/drivers/innobackupex.py
@@ -42,7 +42,7 @@ class InnoBackupEx(mysql_base.MySQLBaseRunner):
cmd = ('innobackupex'
' --stream=xbstream'
' --parallel=2 ' +
- self.user_and_pass + ' %s' % self.default_data_dir +
+ self.user_and_pass + ' %s' % self.datadir +
' 2>' + self.backup_log
)
return cmd + self.zip_cmd + self.encrypt_cmd
@@ -111,7 +111,7 @@ class InnoBackupExIncremental(InnoBackupEx):
' --stream=xbstream'
' --incremental'
' --incremental-lsn=%(lsn)s ' +
- self.user_and_pass + ' %s' % self.default_data_dir +
+ self.user_and_pass + ' %s' % self.datadir +
' 2>' + self.backup_log)
return cmd + self.zip_cmd + self.encrypt_cmd
diff --git a/backup/drivers/mysql_base.py b/backup/drivers/mysql_base.py
index 6389cdb9..59c94bb0 100644
--- a/backup/drivers/mysql_base.py
+++ b/backup/drivers/mysql_base.py
@@ -53,7 +53,8 @@ class MySQLBaseRunner(base.BaseRunner):
last_line = output.splitlines()[-1].strip()
if not re.search('completed OK!', last_line):
- LOG.error("Backup did not complete successfully.")
+ LOG.error(f"Backup did not complete successfully, last line:\n"
+ f"{last_line}")
return False
return True
diff --git a/backup/install.sh b/backup/install.sh
index 19177baf..a2aad105 100755
--- a/backup/install.sh
+++ b/backup/install.sh
@@ -9,23 +9,25 @@ case "$1" in
curl -sSL https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb -o percona-release.deb
dpkg -i percona-release.deb
percona-release enable-only tools release
+ apt-get update
apt-get install $APTOPTS percona-xtrabackup-$2
- apt-get clean
+ rm -f percona-release.deb
;;
"mariadb")
apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
add-apt-repository "deb [arch=amd64] http://mirror2.hs-esslingen.de/mariadb/repo/10.4/ubuntu $(lsb_release -cs) main"
apt-get install $APTOPTS mariadb-backup
- apt-get clean
;;
"postgresql")
apt-key adv --fetch-keys 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
add-apt-repository "deb [arch=amd64] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main"
apt-get install $APTOPTS postgresql-client-12
- apt-get clean
;;
*)
echo "datastore $1 not supported"
exit 1
;;
esac
+
+apt-get clean
+rm -rf /var/lib/apt/lists/*