Google Photos⚓
Summary⚓
A cron job has been setup to make a full backup of my Google Photos account, Maria's & Harold's at a certain interval. This is done utilizing the following:
- Google Photos API
- Rclone
- Cron
- Backblaze B2
The task is broken down into the following three jobs:
- Archive Photos - Copies all photos from Google Photos to Ubuntu Server.
- Album Backup - Copies all photos from all Google Photos albums to Ubuntu Server.
- Copy to B2 - Backs up all photos and albums from Ubuntu Server to B2.
Commands⚓
The following are the commands used for each job:
###################################################
########### Dave's Google Photos Backup ###########
###################################################
## Dave's Google Photos Archive Backup
0 */12* ** rclone sync dave:media/by-month /storage/google-photos/dave/archive/ --verbose --log-file=/storage/google-photos/logs/dave/gphotos.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/8453a362-4b28-4921-98cf-864238e62e78
## Dave's Google Photos Albums Backup
0 12 ** 1 rclone sync dave:album /storage/google-photos/dave/albums/ --verbose --log-file=/storage/google-photos/logs/dave/gphotos-albums.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/d5957ee4-c779-4ba0-9a75-0edc7a0e76f2
## Dave's Google Photos All to B2
0 18 ** 2 rclone sync /storage/google-photos/dave/ b2:GPhotos-Backup/Dave --verbose --log-file=/storage/google-photos/logs/dave/b2.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/6fdcf161-7bef-4980-9802-9284098f8563
## Dave's Google Photos All to NAS
0 0 ** * rclone sync /storage/google-photos/dave/ nas:Photos --verbose --log-file=/storage/google-photos/logs/dave/nas.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/d1145117-5ca1-4a10-8dc0-756f8184c655
###################################################
########### Harold Google Photos Backup ###########
###################################################
## Harold's Google Photos Archive Backup
0 19 ** * rclone sync hats:media/by-month /storage/google-photos/hats/archive/ --verbose --log-file=/storage/google-photos/logs/hats/hatsphotos.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/b72f1005-2023-4e53-97e1-9ac559c026b0
## Harold's Google Photos Albums Backup
0 13 ** 1 rclone sync hats:album /storage/google-photos/hats/albums/ --verbose --log-file=/storage/google-photos/logs/hats/hats-albums.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/f1c5b3cb-736f-4fbf-9e61-e09ca9a35a5e
## Harold's Google Photos All to B2
0 20 ** 1 rclone sync /storage/google-photos/hats/ b2:GPhotos-Backup/Harold --verbose --log-file=/storage/google-photos/logs/hats/hats-b2.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/1f1f88a2-2b29-49d9-ae4f-c5f485d683c2
####################################################
########### Maria's Google Photos Backup ###########
####################################################
## Maria's Google Photos Archive Backup
0 21 ** * rclone sync maria:media/by-month /storage/google-photos/maria/archive/ --verbose --log-file=/storage/google-photos/logs/maria/mariaphotos.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/7fa3b3cd-7cc9-462c-8bf8-f18c2e2c4ba8
## Maria's Google Photos Albums Backup
0 11 ** 1 rclone sync maria:album /storage/google-photos/maria/albums/ --verbose --log-file=/storage/google-photos/logs/maria/maria-albums.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/0813ebaa-6152-4876-aa8b-bed400959dae
## Maria's Google Photos All to B2
0 15 ** 3 rclone sync /storage/google-photos/maria/ b2:GPhotos-Backup/Maria --verbose --log-file=/storage/google-photos/logs/maria/maria-b2.log && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/bb206645-5b85-468a-8bb9-62c65417534f
My Photos⚓
The first job represents the 'Archive Photos' job and each part of the job is broken down as follows:
- Rclone runs at a predefined interval, copying all photos from Google Photos and organizing them by Year > Month > FILE, then stores them in
/storage/google-photos/<user>/archive/
. - The
--verbose
flag states that the command should give information about every file that is transferred. - The
--log-file
flag states that all output should be logged and stored in the/storage/google-photos/logs/<user>/gphotos.log
. - The final part is the healthchecks.io ping URL. This states that each time the job runs, the job will automatically ping that URL, reporting a successful or unsuccessful ping. If the ping is unsuccessful, I will receive a Slack notification saying so.
Album Backup⚓
The second job represents the 'Album Backup' job. The breakdown is as follows:
- Rclone runs at a predefined interval. All albums are copied from Google Photos and organizing them by Albums > FILE, which are stored at
/storage/google-photos/<user>/albums/
. - The
--verbose
flag states that the command should give information about every file that is transferred. - The
--log-file
flag states that all output should be logged and stored in the/storage/google-photos/logs/<user>/gphotos-albums.log
. - The final part is the healthchecks.io ping URL. This states that each time the job runs, the job will automatically ping that URL, reporting a successful or unsuccessful ping. If the ping is unsuccessful, I will receive a Slack notification saying so.
Copy to B2⚓
The final job represents sending the folders and files from both previous jobs directly to Backblaze B2. The breakdown is as follows:
- Rclone runs at a predefined interval. All copied content from Google Photos is sent to B2 and organized properly. Everything is stored in the GPhotos-Backup bucket on B2.
- The
--verbose
flag states that the command should give information about every file that is transferred. - The
--log-file
flag states that all output should be logged and stored in the/storage/google-photos/logs/<user>/b2.log
. - The final part is the healthchecks.io ping URL. This states that each time the job runs, the job will automatically ping that URL, reporting a successful or unsuccessful ping. If the ping is unsuccessful, I will receive a Slack notification saying so.
Logrotate⚓
Logrotate is utilized to make sure the log file doesn't become too large. This is important as the logfiles for Rclone can become very large quickly.
The logrotate config file can be found in /etc/logrotate.conf
.
The syntax to rotate the logs is as follows:
/storage/google-photos/logs/<user>/*.log {
rotate 7
weekly
missingok
notifempty
delaycompress
compress
}
References⚓
- https://rclone.org/docs/
- https://rclone.org/googlephotos/
- https://rclone.org/b2/
- https://www.howtogeek.com/451262/how-to-use-rclone-to-back-up-to-google-drive-on-linux/
- https://nsuchy.me/2020/02/21/how-to-automate-your-own-backups-with-rclone-and-crontab-on-any-unix-linux-based-computer/
- https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04