Skip to content

Commit

Permalink
Merge pull request #11 from crishoj/stream-command-option
Browse files Browse the repository at this point in the history
Stream command option
  • Loading branch information
omegazeng authored Mar 23, 2022
2 parents 040c773 + 1b9e462 commit b27f7d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions run-mariabackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ MYSQL_USER=backup
MYSQL_HOST=localhost
MYSQL_PORT=3306
BACKCMD=mariabackup # Galera Cluster uses mariabackup instead of xtrabackup.
GZIPCMD=gzip # pigz # pigz (a parallel implementation of gzip) could be used if available.
GZIPCMD=gzip # pigz (a parallel implementation of gzip) could be used if available.
STREAMCMD=xbstream # sometimes named mbstream to avoid clash with Percona command
BACKDIR=/data/mysql_backup
FULLBACKUPCYCLE=604800 # Create a new full backup every X seconds
KEEP=3 # Number of additional backups cycles a backup should be kept for.
Expand Down Expand Up @@ -139,15 +140,15 @@ then
mkdir -p $TARGETDIR

# Create incremental Backup
$BACKCMD --backup $USEROPTIONS $ARGS --extra-lsndir=$TARGETDIR --incremental-basedir=$INCRBASEDIR --stream=xbstream | $GZIPCMD > $TARGETDIR/backup.stream.gz
$BACKCMD --backup $USEROPTIONS $ARGS --extra-lsndir=$TARGETDIR --incremental-basedir=$INCRBASEDIR --stream=$STREAMCMD | $GZIPCMD > $TARGETDIR/backup.stream.gz
else
echo 'New full backup'

TARGETDIR=$BASEBACKDIR/`date +%F_%H-%M-%S`
mkdir -p $TARGETDIR

# Create a new full backup
$BACKCMD --backup $USEROPTIONS $ARGS --extra-lsndir=$TARGETDIR --stream=xbstream | $GZIPCMD > $TARGETDIR/backup.stream.gz
$BACKCMD --backup $USEROPTIONS $ARGS --extra-lsndir=$TARGETDIR --stream=$STREAMCMD | $GZIPCMD > $TARGETDIR/backup.stream.gz
fi

MINS=$(($FULLBACKUPCYCLE * ($KEEP + 1 ) / 60))
Expand Down

0 comments on commit b27f7d8

Please sign in to comment.