~2 min read • Updated Mar 1, 2026
1. Why Use Borg for DirectAdmin Backups?
If you are not satisfied with FTP as a remote backup method and want a more advanced solution, Borg is an excellent choice. It provides:
- Incremental backups
- Deduplication and compression
- Retention policies (daily, weekly, monthly)
- Local or remote repository support
2. Step 1: Create DirectAdmin Backups Without Heavy Data
Go to:
Admin Backup/Transfer → ScheduleThen configure:
- Schedule backups daily (or as needed)
- Unselect
Domains DirectoryandE-mail Data - Set backup path to
/home/admin/admin_backups
3. Step 2: Install Borg
CentOS:
yum -y install epel-release
yum -y install borgbackup
Debian/Ubuntu:
apt install borgbackup
4. Step 3: Initialize a Borg Repository
Local repository:
borg init --encryption=none /backups
Remote repository:
REPOSITORY=borgbackup@YOUR_SERVER_IP:/backups/`hostname -f`
Set up SSH keys for passwordless access if needed.
5. Step 4: Automate Borg Backups After Each DirectAdmin Backup
Create the script:
/usr/local/directadmin/scripts/custom/all_backups_post.sh
Insert the following content:
#!/bin/sh
REPOSITORY=borgbackup@YOUR_SERVER_IP:/backups/`hostname -f`
borg create -v --stats \
$REPOSITORY::'{hostname}-{now:%Y-%m-%d_%H:%M}' \
/home \
/var/www/html \
/etc \
/usr/local/directadmin > /tmp/borg-stat.tmp 2>&1
if [ "$?" -le 1 ]; then
borg prune -v $REPOSITORY --prefix '{hostname}-' \
--keep-daily=7 --keep-weekly=4 --keep-monthly=6
else
date >> /tmp/borg-stat.tmp
mail -s "backup failed on server `hostname -f`" [email protected] \
< /tmp/borg-stat.tmp
fi
Set permissions:
chmod 700 /usr/local/directadmin/scripts/custom/all_backups_post.sh
6. Retention Policy
The script keeps:
- 7 daily backups
- 4 weekly backups
- 6 monthly backups
You can adjust these values as needed.
7. Restoring From Borg
The repository path is defined in the script. Example:
REPOSITORY=ssh://[email protected]:2200/home/rbackup/`hostname -f`
7.1 List all backups:
borg list ssh://[email protected]:2200/home/rbackup/`hostname -f`
7.2 Mount a specific backup
Create a mount point:
mkdir /mnt/mybackup
Mount the desired backup:
borg mount ssh://[email protected]:2200/home/rbackup/`hostname -f`::server.mycompany.tld-2019-11-13_05:06 /mnt/mybackup
Check contents:
ls -l /mnt/mybackup
7.3 Restore a specific file
cd /mnt/mybackup/home/admin/domains/clientdomain.com/public_html/wp-admin
cp -a index.php /home/admin/
7.4 Unmount the backup
umount /mnt/mybackup
rmdir /mnt/mybackup
8. Restoring Databases
Databases are stored in:
/home/admin/admin_backups/
Extract the desired backup and restore the required database manually.
Written & researched by Dr. Shahin Siami