How to setup a private storage service for automatically sync up your iPhone Photo/Video
井民全, Jing, mqjing@gmail.com
這裡介紹 NextCloud 如何做到一樣的事, 也就是把手機的照片與影片備份到家裡硬碟,而且能夠隨時在手機上看到照片. NextCloud 是原先 owncloud 的創辦人, 因為理念不合, 另外創辦的公司, NextCloud 與 OwnCloud 共用早期呃程式碼, 但分支後, NextCloud 有更多的整合應用, 例如: Talk, Status, Calendar, Mail 系統.
我一直覺得,自己可以架設一個類似 Google Photo 的系統, 因為 Google 免費, 就一直擱著, 現在既然 Google 要收回免費的服務, 那麼正好就來試試安裝設定一下. 讓家裡的儲存空間與手機的照片庫, 自動同步備份. 徹底解決照片分享、備份、手機容量的問題.
資料儲存最重要的就是要讓人安心, 也不用擔心, 因為斷電或其他意外, 使得 NextCloud docker instance crashed 造成資料無法消失,.
NextCloud Docker 版的所有東西, 全部都會放在 host 的 volume 目錄中, 你隨時可以用你熟悉的方式做備份. 你的資料完全看得到, 摸得到.
In this document, I'll show how to install a simple NextCloud server and use the iPhone App "Next Cloud" to automatic backup the photos and videos to the next cloud volumes.
For backup solution, the moet important question is Where is my data stored? Here, Next Cloud provide not only a integrated interface for upload but also a original folder form for your data, photo, and video files.
We can see the Data
For example, you can easy find out a user jing's all data/photo/video at the following location, and the .../data/jing. Know the location, you can use your familiar way to backup your data.
Data is saved even the system crashed
All data in Next cloud are stores in the unnamed docker volume volume /var/www/html. The docker daemon stores data within the docker directory /var/lib/docker/volumes/.... That means your data is saved even if the container crashes, is stopped or deleted.
Here is the procedure.
1. Server Site
1.1. Requirement
In this document, I will use Ubuntu 22.04 LTS for testing. It's ok and can be successful to install.
1.2. Install Docker
1.3. Install and Run NextCloud
For more options, you can reference the Quick Reference Guide[3].
Q: If I want to edit config.php, where is the nextcloud?
=> Check the host folder at /var/lib/docker/volumes/nextcloud/
Verify
Get an other machine and launch a browser to the http://[nextcloud-ip].
2. Dashboard
To see the status
3. Configuration
3.1. How about the servier crashed or restart?
Quick response: They are located at the host folders and will not to be destroyed after the docker instances removed or crashed or restart.
From the document[2],
That means, all your data was stored at the host location, /var/lib/docker/volumes/. If you want to edit the config.php, at host, you can edit the folder /var/lib/docker/volumes/nextcloud/_data/config/config.php. Don't forget sudo.
e.g.
3.2. Where is my Data?
For users admin and jing, you can check the folder /var/lib/docker/volumes/nextcloud/_data/data/admin and the .../data/jing. Check the examples was listed at below.
3.3. Edit config.php
vi /var/lib/docker/volumes/nextcloud/_data/config/config.php
Verify
Result: PASS
4. iPhone App
4.1. Install the App
Step 1: Install the NextCloud App from AppStore
Step 2: Login to your NextCloud server
If everything is ok, you will see these ...
4.2. Configuration to Auto upload photo and video
Click the [More] at the bottom and then select the [Settings]
5. Testing
5.1. Scenario 1: Restart the service
Instructions
sudo docker stop [server-id] and then start the [servier-id]
Result: Pass. All data reserved.
5.2. Scenario 2: Reinstall the service
Instructions
sudo docker rm [server-id] and sudo docker image rm [image id
install the service, again
Result: Pass. All data reserved.
6. Maintenance
For occ command, the page, https://docs.nextcloud.com/server/latest/admin_manual/maintenance/index.html
6.1. Where to run the occ command
Step 1: Into the the Next cloud docker instance
e.g.:
Get the container id of the NextCloud is a6..... and then into the instance.
Step 2: Get the www-data user id
e.g..
Step 3: Using the right user id run occ command, again
E.g.
6.2. Install OCCWeb
Step 1: Launch a Browser: login to the server
Step 2: Install the OCCWeb
User: admin -> Apps -> Tools: OccWeb
Step 3: test OCC command
6.3. Maintenance Mode
(link)
6.3.1. Setup the maintenance mode
From the document, enable the maintenance mode will locks the sessions of all logged-in users, including administrators, and displays a status screen warning that the server is in maintenance mode. Users who are not already logged in cannot log in until maintenance mode is turned off. When you take the server out of maintenance mode logged-in users must refresh their Web browsers to continue working.
However, I got issues prevent me to run occ on the host. So, my alternative method is directly modify the config.php file. There are some interestings options can be setup such as Preview option: OC\Preview\HEIC, OC\Preview\Movie, OC\Preview\PDF, OC\Preview\JPEG; Maintenance options, SSL option, Store files in a swift object storage.
If you are interesting more options in config.php, you can reference to the config paramenters.
Step 1. Edit the config.php
Command
sudo /var/lib/docker/volumes/nextcloud/_data/config/config.php
File: /var/lib/docker/volumes/nextcloud/_data/config/config.php
e.g.
Result
6.3.2. Turn the Maintenance Off
Remove the 'maintenance' => true from the config.php
6.4. Backup
6.5. Restore
7. References
https://github.com/docker-library/docs/blob/master/nextcloud/README.md#persistent-data
The Quick Reference Guide, https://github.com/docker-library/docs/blob/master/nextcloud/README.md
Using the occ command, https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html
Mainentance occ commands, https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#maintenance-commands
Configure.php, https://docs.nextcloud.com/server/22/admin_manual/configuration_server/config_sample_php_parameters.html
8. Development
NextCloud/OwnCloud, dev, sheet