Skip to content

Instantly share code, notes, and snippets.

@raphiz
Created November 12, 2014 22:24
Show Gist options
  • Save raphiz/f72488e2fb54ca055d12 to your computer and use it in GitHub Desktop.
Save raphiz/f72488e2fb54ca055d12 to your computer and use it in GitHub Desktop.
Synchronize FTP server with a local directory (Linux)
#!/usr/bin/env bash
# Requires: curlftpfs, unison and fuse.
# Configuration:
MOUNTPOINT=/mnt/my_ftp_share/
LOCAL="/home/user/directory"
FTP_HOST="example.com"
FTP_USER="user"
FTP_PASS="secrit"
FTP_SUBFOLDER="httpdocs/"
# Mount FTP share
curlftpfs "$FTP_USER:$FTP_PASS@$FTP_HOST" "$MOUNTPOINT"
# Sync and accept defaults
unison -auto "$MOUNTPOINT/$FTP_SUBFOLDER" "$LOCAL"
# Umount
fusermount -u "$MOUNTPOINT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment