Skip to content

↪ Synchronizing Files

This guide provides instructions on how to sync files to your device. You can use the automated sync.sh script for a streamlined experience, or follow the manual instructions for more control.

⚡ Automated Syncing with sync.sh

The scripts/sync.sh script provides an easy way to synchronize a local directory with the device's microSD card over FTP. It uses lftp to mirror the contents, deleting any files on the device that are not present locally.

📦 Dependencies

You must have lftp installed on your system.

sudo apt install lftp
brew install lftp

⚙ Configuration

There are two ways to configure the script:

  • Copy the template .env File (Recommended):
cp scripts/.env.tmpl scripts/.env
  • Edit scripts/.env with your device's IP address, FTP credentials, and web server credentials (if authentication is enabled).

scripts/.env

FTP_HOST="192.168.2.169"
FTP_USER="user"
FTP_PASSWORD="password"
WEB_SERVER_USER=""
WEB_SERVER_PASSWORD=""
LOCAL_DIR="data"
REMOTE_DIR="/"

Tip

You can override the .env file settings by passing environment variables directly.

📝 Script Usage

  1. Make sure the device is in FTP Server Mode.
  2. Run the script from the scripts directory:
task sync
cd scripts
./sync.sh

Example with Command-Line Arguments:

This command syncs a specific local directory to the device, overriding any settings in .env. If the web server is authenticated, you must also pass the credentials.

./scripts directory

FTP_HOST="192.168.1.100" \
WEB_SERVER_USER="admin" \
WEB_SERVER_PASSWORD="password" \
LOCAL_DIR="path/to/your/pictures" \
./sync.sh

🔧 Manual Syncing

If you don't want to use the sync.sh script, you can manually sync a directory using lftp.

lftp -c "
set ftp:ssl-allow no;
open -u '<FTP_USER>','<FTP_PASSWORD>' '<FTP_HOST>';
mirror -R --delete --verbose --only-missing --no-perms --parallel=1 '<LOCAL_DIR>' '<REMOTE_DIR>';
"

🔗 References