A Bash script for safe simple file synchronization between a local folder and a remote system using rsync. Supports push (local → remote) and pull (remote → local) operations with interactive prompts to confirm deletions. The script is configurable via a separate config file for easy management.
- Two-way sync: Push files to a remote host or pull files to your local machine.
- Safety checks: Prompts before deleting files to prevent accidental data loss.
- Config-driven: Manage hosts and directories in a simple config file.
- Uses rsync for efficient and reliable file transfers.
- rsync installed
- SSH access to remote system
- Write permission to destination folder.
Run the script via an alias (filesync) with one of the following options:
filesync push # Sync local directory to remote
filesync pull # Sync remote directory to local
filesync --help # Display help message
- Clone the repository
git clone https://github.com/royborgen/filesync.git
cd filesync
- Make the script executable
chmod +x filesync.sh
-
Rename
config.sampletoconfigand edit variables as needed -
You can now sync your files by executing
./filesync.shfrom the scripts folder
It is recommended to create an alias for simple execution.
- Create the file
~/.bash_aliases(or edit if it already exist). Add the following line:
alias filesync="$HOME/path/to/filesync/filesync.sh"
- Reload bash by typing the command
bash
You can now execute the script by typing the command filesync from anywhere.
This script is open source and licensend under the GPL-2.0 license. See the projects LICENSEfile for details.