/Yi-Outdoor-Camera-1080p-backup-script

Backup shell script for Yi Outdoor Camera 1080p

Primary LanguageShellGNU General Public License v3.0GPL-3.0

Backup shell script for Yi Outdoor Camera 1080p


Purpose

I have a chance to work on a Yi Outdoor 1080p Camera, main purpose is to find out a way to save recorded videos to a larger storage in order to have more days of video backup. This is because SD card will be overwritten once storage full, a 64GB SD card can store less than 7 days video recorded in 1080p.



Camera's default feature for storage

The only methods to save more videos in the camera's default feature is:-
  1. Increase SD card storage (but we don't know if the camera will work well on SD card larger than max storage as stated in the specification - 64GB).
  2. Pay to use Yi Cloud (never try out, but I assumed cloud storage can be customized with $$$).


Yi Camera Hack

I found Yi Camera's firmware can be hacked (https://github.com/TheCrypt0/yi-hack-v4) to have more features such as SSH, FTP, RTSP, etc. This is a good start and I decided to try it out. It is simple, just follow the instruction and extract 2 firmware files to SD card's root folder will do.

At first I was thinking to use RTSP, but it is not too heavy for backup only solution, therefore FTP is the final choice and meet the requirement.


Setup

I need a hard disk for storage and an attached computer to work as FTP client to download data from the camera. NAS (Network Attached Storage) is the best solution but I have only one to backup my data, don't want to mess it up. Therefore, I use a single computer from my Odroid MC1, which is known as Odroid MC1 Solo - https://www.hardkernel.com/shop/odroid-mc1-solo/. It is equipped with 2GB RAM, ethernet port and USB port.


Hardware:-

  • Yi Outdoor Camera
  • Odroid MC1 Solo
  • External USB hard disk

Software:-

  • Hacked firmware for Yi Outdoor Camera
  • Odroid MC1 default operating system (Ubuntu 16.04)

First of all I formatted hard disk to ext4 because it will be operating under Ubuntu and the backup script is written in shell script. Formatted hard disk mounted to folder /mnt/hdd1. There are 2 shell scripts in this repository, core script is backup141.sh, you can edit the script to change constants to fit your environment:-

  • TOTAL_DAYS_KEEP : Total days of video recorded that you wish to keep in the harddisk, the script will delete old videos before it started to backup.
  • IP_ADDRESS : IP of the camera, I have configured it as fixed local IP in my router.
  • BACKUP_MAINFOLDER : main backup folder in the harddisk
  • BACKUP_SUBFOLDER : sub backup folder (it is not require to change unless Yi Camera change it's default folder)

I am using WGET to access to camera's FTP server (* while preparing this documentation, I just noticed that I hardcoded IP in the WGET, you may replace it with IP_ADDRESS constant instead).

In order to run the script in cron with proper documented log file with datetime as filename, I created another parent shell script - backupall.sh. This backupall.sh will run backup141.sh with proper datetime filename's log file, and it can add more core scripts for extra camera. Again, you can change the constants for your needs.

Command to add to cron:-

sudo -s
crontab -e
Then run script every hour:-
0 * * * * /bin/bash -c "/mnt/hdd1/backupall.sh" 2>&1


License

This application is developed by Season Wong. It is free software and licensed under the GNU General Public License v3.0 (GPLv3).