A powerful and interactive Bash script for syncing Debian repositories using debmirror. It supports multiple distributions, optional suites, section filtering, custom mirrors, and robust lockfile handling β all with detailed logging and colorful terminal output.
- Interactive or automated modes:
--all: sync all supported distros--manual: specify a custom mirror URL and codename
- Supports syncing:
- Base distributions:
stretch,buster,bullseye,bookworm,trixie,forky,sid - Optional suites:
-security,-updates,-backports
- Base distributions:
- Section filtering:
- Choose from
main,main,contrib, ormain,contrib,non-free
- Choose from
- Custom mirror URL support for alternative sources
- Lockfile detection and cleanup to prevent conflicts
- Excludes large desktop environments and multimedia packages to save space
- Logs activity to
/var/log/debmirror-update.log - Color-coded terminal output for better readability
Ensure the following dependencies are installed:
- Bash (tested on Debian-based systems)
- debmirror
sudo apt install debmirror
- Standard utilities:
rsync,curl,awk,pgrep,tee,du
Make the script executable:
chmod +x debian-mirror-sync.shRun interactively:
sudo ./debian-mirror-sync.shOr use automation flags:
sudo ./debian-mirror-sync.sh --all
sudo ./debian-mirror-sync.sh --manualFollow the prompts to select distros, suites, and sections.
Estimated disk usage:
- Single distro (main only): ~50β80 GB
- Full mirror (all distros + suites + sections): 500β1000 GB+
Actual usage depends on selections and exclusions.
To use the mirrored packages on other machines:
-
Transfer the mirror directory to a server:
rsync -a /Debian-Repository/ user@server:/srv/apt-mirror/
-
Serve it via HTTP (e.g., using Nginx or Apache)
-
Add this to client machines:
echo "deb [trusted=yes] http://your-server/apt-mirror bullseye main contrib non-free" | sudo tee /etc/apt/sources.list.d/offline.list sudo apt update
This project is licensed under the MIT License. Feel free to modify and share.