Installing Copidar on Debian
Copidar can be installed on Debian using two primary methods: via the APT package manager (recommended for stability) or from source code (for the latest version).
APT Package Manager: Update the package list and install Copidar with dependencies:
sudo apt update
sudo apt install copidar
Verify installation by checking the version:
copidar --version
Source Code Compilation: For the latest features, clone the GitHub repository, install dependencies (build-essential, git, cmake), and compile:
sudo apt install build-essential git cmake
git clone https://github.com/Copidar/Copidar.git
cd Copidar
mkdir build && cd build
cmake .. && make
sudo make install
Confirm installation with copidar --version.
Basic Usage Scenarios
Copidar’s core functionality includes directory monitoring, file synchronization, and event handling. Key commands include:
Monitor a Directory: Track changes in a directory (non-recursive by default):
copidar /path/to/directory
Recursive Synchronization: Sync files and subdirectories between source and destination:
copidar -r /source/directory /destination/directory
Verbose Mode: Enable detailed output to track file changes:
copidar -v /path/to/directory
Exclude Files/Directories: Ignore specific files (e.g., *.tmp) or directories (e.g., cache/) during sync:
copidar -r --exclude '*.tmp' --exclude 'cache/' /source /destination
Delete Extra Files: Remove files in the destination that don’t exist in the source (use with caution):
copidar -r -d /source /destination
Timer-based Synchronization: Use cron to automate sync tasks (e.g., every 5 minutes). Add this line to your crontab (crontab -e):
*/5 * * * * copidar -r -v /source /destination > /var/log/copidar.log 2>&1
```.
Configuration via YAML File
For advanced customization, Copidar uses a YAML configuration file (default: ~/.config/copidar/config.yaml). Example configuration to monitor multiple directories and trigger a script on file changes:
watch_directories:
- /path/to/watch
- /another/path
event_handlers:
- command: /path/to/script.sh # Script to execute on events
events: # Trigger events
- create
- modify
- delete
Start Copidar with the config file using:
copidar -c ~/.config/copidar/config.yaml
```.
**Automation and Integration**
Copidar integrates seamlessly with Debian’s native tools for automation:
- **Cron Jobs**: Schedule periodic syncs (as shown above) to ensure files stay up-to-date without manual intervention.
- **Shell Scripts**: Wrap Copidar commands in scripts for complex workflows (e.g., backup followed by notification). Example script (`run_copidar.sh`):
```bash
#!/bin/bash
copidar -c /path/to/config.yaml >> /var/log/copidar.log 2>&1
Make the script executable and add it to cron:
chmod +x run_copidar.sh
crontab -e
# Add: 0 * * * * /path/to/run_copidar.sh
```.
**Performance and Logging Best Practices**
- **Optimize Performance**: Avoid monitoring large directories or unnecessary files (e.g., temporary files). Use `--exclude` to filter irrelevant content.
- **Log Management**: Regularly check log files (default: `/var/log/copidar.log`) to troubleshoot issues. Use tools like `tail -f` for real-time monitoring or `logrotate` to manage log size.