Manasset
Manasset
Created
Jun 6, 2021 02:24 AM
Tags
Linux
Docker
Published
Jun 6, 2021
Description

Golang ParsePrivateKey

drone-ssh 不接受 ----BEGIN OPENSSH PRIVATE KEY----- 开头的,需要通过 ssh-keygen -p -m PEM -f ~/.ssh/id_rsa 转换成 ----BEGIN RSA PRIVATE KEY---- 开头的,这个是 inplace的转换
-p' Requests changing the passphrase of a private key file instead of creating a new private key. The program will prompt for the file containing the private key, for the old passphrase, and twice for the new passphrase.

Docker 备份

想要备份 Image、volume里面的文件、开起来的 MySQL的文件

Image

# 备份
docker save image1 image2 | gzip > backup.tar.gz

# 还原
docker load -i backup.tar.gz

Volume

docker inspect volume1 # 得到 mountpoint
cd MOUNTPOINT
tar czf ~/volume_backup.tar.gz .

# 还原
cd MOUNTPOINT
tar xf ~/volume_backup.tar.gz -C .

MySQL

要避免出现 mysqldump: [Warning] Using a password on the command line interface can be insecure.
# 备份
# 在 .env 里面添加 MYSQL_PWD=PASSWORD
docker exec --env-file .env -i mysql_container mysqldump DATABASE | gzip > mysql.dump.sql.gz

gunzip mysql.dump.sql.gz

# 还原
# 在 .env 里面添加 MYSQL_PWD=PASSWORD
docker exec --env-file .env -i mysql_continaer mysql DATABASE < mysql.dump.sql
或者可以用tail去掉第一行
tail -n +2 mysql.dump.sql > mysql.dump.removed.sql