Saturday, February 17, 2024

.::: Restore Transaction Log Backup in MySQL MariaDB :::.

 
corelation with http://teguhth.blogspot.com/2024/02/script-backup-full-differential.html
and http://teguhth.blogspot.com/2023/09/set-up-incremental-backup-restore-in.html

1. backup full & transaction log
[root@teguhth fix]# sh backup_full_script.sh
[root@teguhth fix]# sh backup_log_script.sh

 2. check before restore
select * from teguhth.pembelian;
select * from incrementaldb.my_tbl;
delete from incrementaldb.my_tbl;
delete from teguhth.pembelian;
select * from teguhth.pembelian;
select * from incrementaldb.my_tbl;
 

3. restore manual
# restore full backup <optional>
mysql -uroot -p incrementaldb < /backup/20240217/incrementaldb/[FULL]_incrementaldb_20240217_155359.sql
mysql -uroot -p teguhth < /backup/20240217/teguhth/[FULL]_teguhth_20240217_155359.sql

# restore transaction log backup <mandatory>
mysql --binary-mode -uroot -p incrementaldb < /backup/20240217/incrementaldb/[LOG]_incrementaldb_20240217_155414.sql
mysql --binary-mode -uroot -p teguhth < /backup/20240217/teguhth/[LOG]_teguhth_20240217_155414.sql

or

gunzip -c < /backup/20240217/incrementaldb/[LOG]_incrementaldb_20240217_155414.sql.gz  | mysql -uroot -p -f incrementaldb;
gunzip -c < /backup/20240217/teguhth/[LOG]_teguhth_20240217_155414.sql.gz | mysql -uroot -p -f teguhth;

[root@teguhth teguhth]# gunzip -c < /backup/20240217/incrementaldb/[LOG]_incrementaldb_20240217_155414.sql.gz  | mysql -uroot -p -f incrementaldb;
Enter password:
[root@teguhth teguhth]# gunzip -c < /backup/20240217/teguhth/[LOG]_teguhth_20240217_155414.sql.gz | mysql -uroot -p -f teguhth;
Enter password:
[root@teguhth teguhth]#

 

4. check after restore
select * from teguhth.pembelian;
select * from incrementaldb.my_tbl;

No comments:

Post a Comment

Popular Posts