40 lines
1.3 KiB
Bash
40 lines
1.3 KiB
Bash
|
|
||
|
#!/bin/bash
|
||
|
|
||
|
REMOTE_USER=root
|
||
|
SERVER_ORIGIN_DOMAIN=rozenlab.com
|
||
|
|
||
|
REMOTE_DIR="$REMOTE_USER@$SERVER_ORIGIN_DOMAIN:/backups/"
|
||
|
LOCAL_DIR="/backups/$SERVER_ORIGIN_DOMAIN"
|
||
|
|
||
|
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "mkdir -p /backups"
|
||
|
|
||
|
# Backup web server:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/www_backup.tar.gz -C /var www"
|
||
|
|
||
|
# Backup home dir:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/rozen_backup.tar.gz -C /home rozen"
|
||
|
|
||
|
# Backup sftp dir:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/sftp_backup.tar.gz -C /var/sftp files"
|
||
|
|
||
|
# Backup gitea app.ini:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/gitea_app_ini_backup.tar.gz -C /etc gitea"
|
||
|
|
||
|
# Backup gitea data:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/gitea_data_backup.tar.gz -C /var/lib gitea"
|
||
|
|
||
|
# Backup nginx cfgs:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "tar -czvf /backups/nfinx_cfg_backup.tar.gz -C /etc nginx"
|
||
|
|
||
|
|
||
|
# Backup wordpress database:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "mysqldump -u wp_blog_user -pbdcp8zxzojwz5tuhd3mr wp_blog > /backups/wordpress_backup.sql"
|
||
|
|
||
|
# Backup gitea database:
|
||
|
ssh $REMOTE_USER@$SERVER_ORIGIN_DOMAIN "mysqldump -u gitea -prq8vtahhm63aims8aqbz gitea > /backups/gitea_backup.sql"
|
||
|
|
||
|
|
||
|
# Sync all backups from $REMOTE_DIR to $LOCAL_DIR
|
||
|
rsync -avz --delete $REMOTE_DIR $LOCAL_DIR
|