View previous topic :: View next topic |
Author |
Message |
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
Posted: Sat Oct 19, 2024 12:50 pm Post subject: How do I maintain a copy of remote drive with rsync? |
|
|
I'm getting lazy in my old age - too lazy to fight my way through the rsync man pages, at any rate.
I have a Raspberry Pi running Arch Linux that runs various minor services on my home network. It struck me that I don't have a backup process for it.
It's fairly small, and mostly only a few files being updated on a regular basis (apart from periodic system software updates with pacman). Probably the easiest way to back it up would be to maintain a folder on my desktop machine containing a clone of the entire Pi filesystem, using rsync. That would then get swept up in my usual desktop backup process (which happens to use app-arch/dump). Should disaster strike, I'd hope it would be "mount a new formatted and partitioned SD card locally on the desktop machine, then rsync the entire filesystem back".
I have rsync installed on both the Pi and my desktop. My preference would be to use the rsync daemon as root on the Pi - I have ssh set to deny root.
I'd be most grateful if someone who has a similar setup could post the outlines of commands and rsyncd.conf. So far I've come across --fake-root and --links, which seem essentials. The Arch wiki has a relevant article, but as it's missing both those options, either I'm over- or they're under-thinking it! _________________ Greybeard |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3467
|
Posted: Sat Oct 19, 2024 2:18 pm Post subject: |
|
|
AFAIR this does everything:
rsync -aAXHS
The example rsync conf looks simple enough, probably just need to set path=/, and also chroot=yes is pointless if you're going to expose everything anyway, though it might as well "just work"™ with the default config. I've never used rsync daemon, always tunneled it through ssh. _________________ Make Computing Fun Again |
|
Back to top |
|
|
pingtoo Veteran
Joined: 10 Sep 2021 Posts: 1290 Location: Richmond Hill, Canada
|
Posted: Sat Oct 19, 2024 3:54 pm Post subject: |
|
|
In addition to szatox, I would suggest maintain a exclude list file, so you can easier to manage what is in backup.
I don't have direct rsync backup setup as you plan to do. I use rsnapshot. I went a little bit crazy by putting the entire rsnapshot setup in a docker container.
So following szator idea and your plan, I will put /etc/rsyncd.conf Code: | uid = root
gid = root
read only = yes
syslog facility = local5
pid file = /var/run/rsyncd.pid
[backup]
path = /
hosts allow = 10.1.1.1/24
exclude from = /etc/rsync_backup_excludes
dont compress = *.gz *.bz2 *.zip
comment = my server backup |
And for /etc/rsync_backup_excludes Code: | # backup all important config files.
+ /etc
# Not backup everything else.
/*
|
The desktop client command will be Code: | rsync -aAXHS pi-server::backup |
These config files are from memory, so there may be syntax error. so let me know if you found error, I will try to correct them. |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
Posted: Sun Oct 20, 2024 11:12 am Post subject: |
|
|
Thanks. _________________ Greybeard |
|
Back to top |
|
|
Bob P Advocate
Joined: 20 Oct 2004 Posts: 3374 Location: USA
|
Posted: Sun Oct 20, 2024 8:54 pm Post subject: |
|
|
I've done it both ways -- one being the use of an rsync server, the other being rsync over ssh by a non-root user having the right file/directory permissions. If your file permissions allow non-root user/group to access to the directories and the files, rsync as a non-root user over ssh is simpler as there's no need to install an rsync server.
if root file permissions are required it's still possible to perform rsync over ssh as root (without an rsync server) if you allow root ssh access by one machine and deny it everywhere else. it all depends on where you prefer to place your access restrictions. |
|
Back to top |
|
|
|