Sunday, June 4, 2023

::: Test Result Backup from Database NonEncrypted & Restore Database Encrypted and otherwise :::.

A. Continue from
http://teguhth.blogspot.com/2023/06/test-result-backup-from-database.html

backup restore nonencripted/ teguh02 and restore to encripted then continue below
then backup encripted teguhth and restore to nonencripted/ > result success


B. backup & restore again

1. backup database from restore encripted
MariaDB [nonsecretdb]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nonsecretdb        |
| performance_schema |
| secretdb           |
| teguhth            |
+--------------------+
6 rows in set (0.000 sec)
 


MariaDB [nonsecretdb]> show tables;
+-----------------------+
| Tables_in_nonsecretdb |
+-----------------------+
| barang                |
| customer              |
| pasok                 |
| pembelian             |
| suplier               |
+-----------------------+
5 rows in set (0.000 sec)

MariaDB [nonsecretdb]> show create table nonsecretdb.barang;

| barang | CREATE TABLE `barang` (
  `KODE_BARANG` char(6) NOT NULL,
  `NAMA_BARANG` varchar(25) DEFAULT NULL,
  `SATUAN_BARANG` varchar(20) DEFAULT NULL,
  `STOK_BARANG` decimal(4,0) DEFAULT NULL,
  PRIMARY KEY (`KODE_BARANG`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `encrypted`=no |

2. backup database from restore nonencripted/. then


mysqldump -u root -p nonsecretdb --single-transaction --skip-lock-tables > db_nonsecretdbnonencripted.sql ;

[root@teguhth data]# pwd
/data
[root@teguhth data]# ls
db_nonencriptedbarang.sql  db_nonencripted.sql  db_teguhthencripted.sql  table_barangencripted.sql
[root@teguhth data]# mysqldump -u root -p nonsecretdb --single-transaction --skip-lock-tables > db_nonsecretdbnonencripted.sql ;
Enter password:
[root@teguhth data]#


3. copy backup from encripted to nonencripted/

[root@teguhth data]# pwd
/data
[root@teguhth data]# ls
db_nonencriptedbarang.sql  db_nonencripted.sql  db_teguhthencripted.sql  table_barangencripted.sql
[root@teguhth data]# mysqldump -u root -p nonsecretdb --single-transaction --skip-lock-tables > db_nonsecretdbnonencripted.sql ;
Enter password:
[root@teguhth data]# ls
db_nonencriptedbarang.sql  db_nonencripted.sql  db_nonsecretdbnonencripted.sql  db_teguhthencripted.sql  table_barangencripted.sql
[root@teguhth data]# sftp root@teguhth02:/data
root@teguhth02's password:
Permission denied, please try again.
root@teguhth02's password:
Connected to teguhth02.
Changing to: /data
sftp> ls
db_nonencripted.sql              db_nonencriptedbarang.sql        db_teguhthencripted.sql          table_barangencripted.sql
sftp> put db_nonsecretdbnonencripted.sql
Uploading db_nonsecretdbnonencripted.sql to /data/db_nonsecretdbnonencripted.sql
db_nonsecretdbnonencripted.sql                                                                    100% 8021     8.0MB/s   00:00
sftp> ls
db_nonencripted.sql              db_nonencriptedbarang.sql        db_nonsecretdbnonencripted.sql   db_teguhthencripted.sql
table_barangencripted.sql
sftp> exit
[root@teguhth data]#


4. restore to database nonencripted/

mysql -u root -proot nonsecretdb < db_nonsecretdbnonencripted.sql;


4. Check Final
 
[root@teguhth02 ~]# cd /data/
[root@teguhth02 data]# ls
db_nonencriptedbarang.sql  db_nonencripted.sql  db_nonsecretdbnonencripted.sql  db_teguhthencripted.sql  table_barangencripted.sql
[root@teguhth02 data]# mysql -u root -proot nonsecretdb < db_nonsecretdbnonencripted.sql;
[root@teguhth02 data]#
[root@teguhth02 data]#


MariaDB [nonsecretdb]> SELECT  NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID,@@hostname,@@version FROM information_schema.INNODB_TABLESPACES_ENCRYPTION;
Empty set (0.000 sec)

MariaDB [nonsecretdb]> SELECT  NAME, ENCRYPTION_SCHEME, CURRENT_KEY_ID,@@hostname,@@version FROM information_schema.INNODB_TABLESPACES_ENCRYPTION;
+--------------------+-------------------+----------------+------------+-----------------+
| NAME               | ENCRYPTION_SCHEME | CURRENT_KEY_ID | @@hostname | @@version       |
+--------------------+-------------------+----------------+------------+-----------------+
| nonsecretdb/barang |                 0 |              1 | teguhth02  | 10.5.20-MariaDB |
+--------------------+-------------------+----------------+------------+-----------------+
1 row in set (0.000 sec)

MariaDB [nonsecretdb]> show tables;
+-----------------------+
| Tables_in_nonsecretdb |
+-----------------------+
| barang                |
| customer              |
| pasok                 |
| pembelian             |
| suplier               |
+-----------------------+
5 rows in set (0.000 sec)

MariaDB [nonsecretdb]>

MariaDB [nonsecretdb]> show create table barang;

| barang | CREATE TABLE `barang` (
  `KODE_BARANG` char(6) NOT NULL,
  `NAMA_BARANG` varchar(25) DEFAULT NULL,
  `SATUAN_BARANG` varchar(20) DEFAULT NULL,
  `STOK_BARANG` decimal(4,0) DEFAULT NULL,
  PRIMARY KEY (`KODE_BARANG`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `encrypted`=no |

MariaDB [nonsecretdb]> show create table barang;


5. restore success without encripted. cause original nonencripted/

 




No comments:

Post a Comment

Popular Posts