大网数据广告活动
服务器运维问答

Backup remote VPS with Rsync

· 52CE 我爱测

I have a VPS that we will be shutting down soon, so I want to create a full backup of it. I was thinking about rsync, because if I google linux and backup words, I constantly get hit by rsync, so why the hell not. :) However, her…

问题原文

原帖链接 · Bert · CC BY-SA 3.0

I have a VPS that we will be shutting down soon, so I want to create a full backup of it. I was thinking about rsync, because if I google linux and backup words, I constantly get hit by rsync, so why the hell not. :) However, here comes the kicker.

The backup machine where I want to backup the VPS in not accessible from the internet. So I can't just use what almost everybody suggests to SSH into the VPS, sudo rsync almost everything and as output mark the backup server. I want to run a bash command that does something similar to dd, so if I run rsync on the remote server, I could mark my local folder as output. Also I have to mention, that root ssh login is not allowed, so I can only SSH into the VPS as a user who can actually turn into sudo, but by default it is just a plain user.

I came up with the following rsync command:

sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /backup/machine/folder

And I wish to use it somehow like this dd command I've used for cloning but the opposite way:

dd if=/dev/sda bs=4096 | pv | ssh root@<<TargetServer-IP>> ”dd of=/dev/sda bs=4096”

已采纳解答

原帖链接 · Bert · CC BY-SA 3.0

I love to post questions here because about 50% of them is being answered by myself. I usually take a few hours to decide to upload the question here, and after that a few mutes later, I get my answer. :) Here is the command:

rsync --dry-run [email omitted]:/ -aAXvh --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /backup/backup/servers/omd

OFC exclude the --dry-run from the command if you want to execute it. Also, you have to add your SSH public key to /root/.ssh/authorized_keys file to make this work.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。