I am trying to backup using xtrabackup and i used the --stream=xbstream method. These backup files are directly then uploaded to the GCP bucket
So i end up with xbstream file on the bucket.
I downloaded that file to the target server.
What do i do now to restore the whole database using the xbstream file?
Hey @Abdul_Hannan_Sohail,
I’m assuming you are using gsutil to copy the backup to GCP. For restore, cp the backup from GC to the machine. Run it through xbstream like this:
mkdir -p /path/to/restore
xbstream -xv -C /path/to/restore < backup.xbs
Then prepare it with PXB as normal.
I recommend you take a look at xbcloud which fully supports Google buckets using S3 mode. I just implemented this for a client last week.
High level: xtrabackup --stream=xbstream | xbcloud put --storage=google ...
This way you don’t need any local disk access. The backup is streamed directly into GCP. Check the documentation for examples on how to restore.
Hi Matthew
Can you share what you mean by PXB as normal?
The command line I used to take backup is:
xtrabackup --datadir=/var/lib/mysql --port=3306 --host=localhost --stream=xbstream --backup --target-dir=./ | /snap/bin/gsutil cp - “gs://bucket/DB.xbstream”
This creates a file called DB.xbstream on the GCP bucket.
I am able to download this to the other target server where I want to restore.
I am not able to see online anywhere step by step on what to do now?
some say to use xtrabackup -x and some say to use apply log something like that and its confusing.
# Copy the backup from gcloud to local fs
/snap/bin/gsutil cp “gs://bucket/DB.xbstream” /path/local/DB.xbstream
# Extract
xbstream -xv -C /path/to/restore < /path/local/DB.xbstream
# Pepare
xtrabackup prepare --target-dir /path/to/restore
# Fix permissions
chown -R mysql:mysql /path/to/restore
# Start mysql
systemctl start mysql
Our documentation has many HOWTO examples on the above.
Thank you for the details
just a question
we dont need to use --copy-back option ?
You would use copy-back if you restored to some other location that wasn’t the mysql datadir.
so for this portion, you are using xbstream to extract. would we need to install xbstream as well? or will installing xtrabackup latest 8 version will automatically have this?
and this “/path/to/restore” is the mysql data directory? the contents of which we would have removed after turning mysql off on the target server?
If you used xbstream to create the backup in the first place, then it should already be on you system. yes, installing PXB includes xbstream.
Correct
Also if we want to setup MySQL chained GTID based replication with xtrabackup
then we would need to use the slave of existing master-slave and deploy mysql native replication on slave to target server after doing a restore from the replica
regarding this method, what variables should be turned on the replica that would have been turned off if we werent using it as a intermediate master.
I used the
but its giving me an error
xb_stream_read_chunk(): wrong chunk magic at offset 0x0.
exit code: 1