Title: Google Photo Sync
Date: 2022/12/26
Tags: linux
Category: calendar
Author: ThomasTsai
Summary: sync photo from google photo service
Google Photo Sync
我手機上的照片都統以sync到google photo去了,被綁架!總之,就先這樣,但是我local還想要keep一份,避免被綁架走不了。所以就找到一個 gphotos-sync 的工具,可以協助我 Linux 上進行自動備份照片。以下步驟來自部落格(我用debian+bash):
sudo apt install python3-pip
echo "export PATH=\"\$PATH:\$HOME/.local/bin\"" >> ~/.bashrc
python3 -m pip install pipenv
mkdir ~/gphotos-sync
cd ~/gphotos-sync
pipenv install gphotos-sync
pipenv run gphotos-sync
and then, 最麻煩就是要到 google 那邊拿 api token
-
到 google cloud 建立專案
-
到 api 清單啟用 photo api ,先到網址: https://console.cloud.google.com/apis/library?project=_ , 選擇剛建立的Project,再去搜尋 "Photos Library API ",再進去啟用,結果如下圖
reference:
https://github.com/gilesknap/gphotos-sync
https://www.linuxuprising.com/2019/06/how-to-backup-google-photos-to-your.html -
再到 https://console.cloud.google.com/ 產生token。左上角下拉式選單選好project,然後左側的導覽選單找"api和服務" 內的 "憑證"
-
新增憑證,要新增 oauth 2.0
新增憑證的時候選電腦版應用程式
You can see the complete procedure for setting up OAuth 2.0 with your new project on https://support.google.com/cloud/answer/6158849
然後下載憑證到
~/.config/gphotos-sync/
執行同步看看
cd gphotos-sync
pipenv run gphotos-sync ~/gphotos-sync
這樣就可以同步了!
crontab 自動同步
寫一支腳本 ~/bin/gphotos-sync.sh
#!/bin/bash
export PATH="/home/thomas/.local/bin:$PATH"
pushd /home/thomas/gphotos-sync
pipenv run gphotos-sync ~/gphotos-sync
popd
編輯並加入 $ crontab -e
17 16 * * * /home/thomas/bin/gphotos-sync.sh
看起來都有好好的同步!
refererence:
https://www.linuxuprising.com/2019/06/how-to-backup-google-photos-to-your.html
https://github.com/gilesknap/gphotos-sync