• Home
  • Features
  • Trial
  • Pricing
  • Demo
  • Docs
  • WuWei Lite

Remote Backup with rsync

This guide explains how to back up important directories from your remote WuWei server to your local machine using rsync.

πŸ“ What You Will Back Up

The following directories will be copied from the remote server:

  • /root/wuwei-docker/mysql/data/backup – MySQL database backups
  • /data/upload – User-uploaded files
  • /data/record – Recorded live session videos

πŸ”§ Server-Side Setup (Remote Server)

1. Install rsync

Debian-based systems:

sudo apt install rsync

RHEL-based systems:

sudo yum install rsync

2. Create a system user for rsync

sudo adduser --system --group rsync

3. Configure rsyncd

Create or edit /etc/rsyncd.conf

uid = rsync
gid = rsync
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log

[mysql]
path = /root/wuwei-docker/mysql/data/backup
read only = true
auth users = rsync
secrets file = /etc/rsyncd.secrets

[upload]
path = /data/upload
read only = true
auth users = rsync
secrets file = /etc/rsyncd.secrets

[record]
path = /data/record
read only = true
auth users = rsync
secrets file = /etc/rsyncd.secrets

4. Create the secrets file

sudo nano /etc/rsyncd.secrets

Add the following (username:password):

rsync:your_secure_password

Then secure the file:

sudo chown root:rsync /etc/rsyncd.secrets
sudo chmod 0640 /etc/rsyncd.secrets

5.Enable and start rsync service

sudo systemctl enable rsync
sudo systemctl start rsync

πŸ’» Local-Side Setup (Backup Server)

1. Install rsync

Debian-based systems:

sudo apt install rsync

RHEL-based systems:

sudo yum install rsync

2. Create password file

Create /root/rsync_password.txt and add the password only:

your_secure_password

⚠️ Important: This password must exactly match the one set in /etc/rsyncd.secrets on the ​remote server​.

Set file permissions:

chmod 0600 /root/rsync_password.txt

3. Create backup script

Create /root/rsync.sh:

#!/usr/bin/env bash

PASSWORD_FILE=/root/rsync_password.txt

REMOTE_USER=rsync

REMOTE_HOST=192.168.100.111

LOCAL_DIR=/root/backup

rsync -avz --delete --password-file=${PASSWORD_FILE} rsync://${REMOTE_USER}@${REMOTE_HOST}/mysql ${LOCAL_DIR}/mysql

rsync -avz --delete --password-file=${PASSWORD_FILE} rsync://${REMOTE_USER}@${REMOTE_HOST}/upload ${LOCAL_DIR}/upload

rsync -avz --delete --password-file=${PASSWORD_FILE} rsync://${REMOTE_USER}@${REMOTE_HOST}/record ${LOCAL_DIR}/record

Replace the β€œREMOTE_HOST” with your remote server IP.

⚠️Warning: --delete ensures files deleted on the remote are also removed locally. Use with caution.

Make it executable:

chmod +x /root/rsync.sh

You can test manually by running:

bash /root/rsync.sh

πŸ“… Schedule Automatic Backup (Optional)

Edit your crontab:

crontab -e

Add the following line to run the script every hour:

0 * * * * /usr/bin/bash /root/rsync.sh > /dev/null 2>&1 &
About Us Contact Us Privacy Policy Terms of Service
© 2025 KOOGUA.NET