vault backup: 2025-08-20 14:35:48

Affected files:
Too many files to list
This commit is contained in:
2025-08-20 14:35:48 +08:00
parent 1d09289423
commit afeb207be2
148 changed files with 13360 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
{
"nodes":[
{"id":"6c6ff5d0e7850ea8","type":"group","x":920,"y":-360,"width":940,"height":1280,"label":"Docker"},
{"id":"e94c9e71b9aeaa89","type":"group","x":440,"y":-360,"width":400,"height":1280,"label":"基本設定"},
{"id":"368b491f60ea8823","type":"group","x":-720,"y":273,"width":480,"height":647,"label":"工具設定"},
{"id":"acb6cf6a8010bb24","type":"group","x":-720,"y":-360,"width":480,"height":349,"label":"備份設定"},
{"id":"d624199752cf24de","type":"text","text":"![[更新與安裝工具]]","x":460,"y":-340,"width":360,"height":120},
{"id":"6875474760fafe7c","type":"text","text":"![[raspi-config]]","x":460,"y":-200,"width":360,"height":140},
{"id":"6e59f6b9f36b24e2","type":"text","text":"![[23.02. 樹莓派/安裝]]","x":-40,"y":132,"width":383,"height":177},
{"id":"990363c918569555","type":"text","text":"# `~/.vimrc`\n![[vim]]","x":-700,"y":293,"width":440,"height":207},
{"id":"e666f52a66610180","type":"text","text":"# `~/.bashrc`\n![[bashrc#Raspberry Pi]]","x":-700,"y":529,"width":440,"height":371},
{"id":"ff16e3814718d144","type":"text","text":"# 設定 crontab\n1. 用[[ddns.sh]]定時更新DNS\n2. 用[[backup_docker_gitea.sh]]備份 gitea docker\n3. 用[[backup_pi.sh]]備份整張SD卡","x":-700,"y":-340,"width":440,"height":150},
{"id":"8dafa10b92b3f0e4","type":"text","text":"# 掛載外接硬碟\n[[硬碟操作]]\n[[fstab]]","x":460,"y":740,"width":360,"height":140},
{"id":"a63a5baed201beda","type":"text","text":"![[設定日誌大小]]","x":460,"y":163,"width":360,"height":180},
{"id":"bc030994aafc5a3b","type":"text","text":"# Setup `bashrc`\n![[bashrc#Raspberry Pi]]","x":460,"y":-37,"width":360,"height":177},
{"id":"f210470376a4829d","type":"text","text":"![[設定Cloudflare DDNS]]","x":460,"y":370,"width":360,"height":150},
{"id":"ef9431e16c90f57f","type":"text","text":"設定![[smb client]]","x":460,"y":540,"width":360,"height":180},
{"id":"b77234a9cdf72aad","type":"text","text":"# 安裝 docker\n[[Docker#安裝]]","x":940,"y":-340,"width":440,"height":120},
{"id":"b900ad17a2841b99","type":"text","text":"# 安裝 Filebrowser\n[官方安裝流程](https://filebrowser.org/installation#docker)","x":1400,"y":-340,"width":440,"height":120},
{"id":"94f3e389e2687b35","type":"text","text":"# 安裝 Watch Tower\n![[Watchtower#或使用 docke-compose.yml|docke-compose.yml]]","x":1400,"y":-190,"width":440,"height":322},
{"id":"d0711febf5985ed5","type":"text","text":"# 安裝nginx-certbot\n教學: [iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天](https://ithelp.ithome.com.tw/m/articles/10301801\n\nGithub: [JonasAlfredsson/docker-nginx-certbot: Automatically create and renew website certificates for free using the Let's Encrypt certificate authority.](https://github.com/JonasAlfredsson/docker-nginx-certbot)","x":940,"y":-190,"width":440,"height":240},
{"id":"8cac63e48dff1f2a","type":"text","text":"# 安裝 Gitea\n官方教學[Installation with Docker](https://docs.gitea.com/installation/install-with-docker)\n\n設定Gmail寄信[Gitea 使用 Gmail 寄信 - 筆記ZONE](https://zonego.tw/2021/11/14/gitea-gmail/)\n","x":940,"y":80,"width":440,"height":140},
{"id":"94fa9ef036dbe62a","type":"text","text":"# Speedtest 測試\n超簡單命令`docker run --rm robinmanuelthiel/speedtest:latest`\n\nGithub: [robinmanuelthiel/speedtest: Check internet bandwidth from a Docker container and save the results to an InfluxDB](https://github.com/robinmanuelthiel/speedtest)","x":940,"y":253,"width":440,"height":207},
{"id":"2a7d5efcc0f2dc0e","type":"text","text":"# 安裝 Portainer\n教學 [Portainer一款圖形化容器管理工具方格子 vocus](https://vocus.cc/article/643e9f74fd89780001b51739)\n\n官網[Portainer: Container Management Software for Kubernetes and Docker](https://www.portainer.io/)","x":940,"y":489,"width":440,"height":191},
{"id":"3f1bf9d99d9d544d","type":"text","text":"# 安裝 [Nextcloud](https://nextcloud.com/)\n![[Nextcloud]]","x":1400,"y":489,"width":440,"height":191},
{"id":"dac28a6e83be787c","type":"text","text":"# 安裝 Grafana\n![[Grafana]]","x":940,"y":700,"width":440,"height":180},
{"id":"fc32cf264646fdec","type":"text","text":"# 安裝 Storj\n![[Storj]]","x":1400,"y":160,"width":440,"height":300},
{"id":"423ff27ca31fdfd9","x":-700,"y":1000,"width":440,"height":120,"type":"text","text":"# 其他\n- [Considerations for a long-running Raspberry Pi # Chris Dzombak](https://www.dzombak.com/blog/2023/12/Considerations-for-a-long-running-Raspberry-Pi.html)"}
],
"edges":[
{"id":"9683c15c63c167c0","fromNode":"6e59f6b9f36b24e2","fromSide":"right","toNode":"e94c9e71b9aeaa89","toSide":"left"},
{"id":"af36558e6c250c94","fromNode":"d624199752cf24de","fromSide":"bottom","toNode":"6875474760fafe7c","toSide":"top"},
{"id":"feff628bc758f1e4","fromNode":"6875474760fafe7c","fromSide":"bottom","toNode":"bc030994aafc5a3b","toSide":"top"},
{"id":"f1a7af20d2d64873","fromNode":"bc030994aafc5a3b","fromSide":"bottom","toNode":"a63a5baed201beda","toSide":"top"},
{"id":"64bd8b56a86d56af","fromNode":"a63a5baed201beda","fromSide":"bottom","toNode":"f210470376a4829d","toSide":"top"},
{"id":"28432d91108beecd","fromNode":"e94c9e71b9aeaa89","fromSide":"right","toNode":"6c6ff5d0e7850ea8","toSide":"left"},
{"id":"d41526184a2da316","fromNode":"6e59f6b9f36b24e2","fromSide":"left","toNode":"acb6cf6a8010bb24","toSide":"right"},
{"id":"c9b1b55f4cf045bb","fromNode":"6e59f6b9f36b24e2","fromSide":"left","toNode":"368b491f60ea8823","toSide":"right"},
{"id":"530b061da2036833","fromNode":"6e59f6b9f36b24e2","fromSide":"left","toNode":"423ff27ca31fdfd9","toSide":"right"}
]
}

View File

@@ -0,0 +1,20 @@
```shell
#!/bin/sh
WORK_DIR="/home/awin/docker/gitea"
SAVE_PATH="/media/upload"
NOW_DATETIME="$(date +'%Y%m%d_%H%M%S')"
BACKUP_FILE_PATH="$SAVE_PATH/docker_backup/gitea/backup_docker_gitea_$NOW_DATETIME.tar"
BACKUP_CMD="sudo tar -cvf $BACKUP_FILE_PATH data docker-compose.yml"
echo "$BACKUP_FILE_PATH"
echo "$(date +'%F %R:%S'): Backup start. CMD = $BACKUP_CMD" > /home/awin/log/backup_docker_gitea.log
mkdir -p $SAVE_PATH/docker_backup/gitea
sudo docker compose -f $WORK_DIR/docker-compose.yml down
cd $WORK_DIR
$BACKUP_CMD
sudo docker compose -f $WORK_DIR/docker-compose.yml up -d
echo "$(date +'%F %R:%S'): Backup finished." >> /home/awin/log/backup_docker_gitea.log
```

View File

@@ -0,0 +1,15 @@
```shell
#!/bin/sh
NOW_DATETIME="$(date +'%Y%m%d_%H%M%S')"
SAVE_FOLDER="/media/upload/pi_backup"
SAVE_FILENAME="pi4_$NOW_DATETIME.img"
CMD="sudo /home/awin/bin/image-utils/image-backup -i $SAVE_FOLDER/$SAVE_FILENAME"
LOG_FILE="/home/awin/log/backup_pi4.log"
mkdir -p $SAVE_FOLDER
echo "$(date +'%F %R:%S'): Backup start. CMD = $CMD" > $LOG_FILE
$CMD
echo "$(date +'%F %R:%S'): Backup finished." >> $LOG_FILE
```

View File

@@ -0,0 +1,40 @@
## `/home/awin/script/ddns.sh`
```bash
#!/bin/bash
CF_ACCESS_TOKEN=033xQP4_ZpTq3sSkeftz5J6BWw_R9eoDNTba7zfH
CF_ZONE_ID=1d6a623d1780c31544fc86f718dac16e
URLS=('awin.one'
'blog.awin.one'
'ftp.awin.one'
'git.awin.one',
'storj.awin.one')
CF_RECORD_IDS=('d67b2a1b3d7cd520b8e8dad2cb522460'
'69dcc0bd619b1a3d4a71458faff2aa50'
'bd397d9779d42c0b92c9c9c47b765769'
'4eccb48e85f2daa8fefeb92c8cb4b4ee'
'216d631bc860c6a11b62e3a1003f3e3e')
INTERNET_IP=`curl -s http://ipv4.icanhazip.com`
INTERFACE_IP=`ip address show ppp0 | grep ppp0 | grep global | awk '{print$2}'`
DNS_RECORD_IP=`dig +short "${URLS[0]}" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | awk 'NR==1{print}'`
NOW_TIME=`date`
if [ "$INTERNET_IP" != "$DNS_RECORD_IP" ]
then
echo "Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}"
echo "${NOW_TIME}: Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}" > /home/awin/log/ddns.log
for ((i = 0; i < ${#URLS[@]}; i++)); do
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records/${CF_RECORD_IDS[$i]}" \
-H "Authorization: Bearer ${CF_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${URLS[$i]}'","content":"'${INTERNET_IP}'","ttl":120,"proxied":false}'
done
else
echo "No change: ${INTERNET_IP}"
echo "${NOW_TIME}: No change: ${INTERNET_IP}" > /home/awin/log/ddns.log
fi
```
### 參考
- [5 分鐘整合 Cloudflare API 實做 Cloudflare DDNS 動態 IP 對應網址](https://blog.toright.com/posts/7333/cloudflare-ddns)
- [自架 DDNS 教學:用 Cloudflare API 達成多域名同步更新! | by Rex | Medium](https://blog.rexyuan.com/%E7%94%A8-cloudflare-dns-api-%E4%BE%86%E9%81%94%E6%88%90-ddns-adaee3c5a84d)

View File

@@ -0,0 +1,3 @@
## `raspi-config`
1. 打開ssh與vnc
2. 開機進入console

View File

@@ -0,0 +1,5 @@
1. 到[官網](https://www.raspberrypi.com/software/)下載`imager`
2. 記得在`imager`裡面設定
1. ssh public key
2. WIFI
3. account/password

View File

@@ -0,0 +1,3 @@
1. `sudo apt update`
2. `sudo apt upgrade -y`
3. `sudo apt install dnsutils`

View File

@@ -0,0 +1,3 @@
用[[crontab]]設定[[ddns.sh]]
1. `crontab -e`
2. 加入 `*/15 * * * * /home/awin/script/ddns.sh`

View File

@@ -0,0 +1,7 @@
打開`/etc/systemd/journald.conf`
- `SystemMaxUse=1G`
- `RuntimeMaxUse=100M`
![[journalctl#重啟日誌]]
journalctl使用說明[[journalctl]]