How to use rsync with a different port?

Hi,
i am trying to figure out how to backup my box with rsync but with a different port.
i have tried to modify the backup.py[1], but that gives me this error when setting up rsync in the web interface:


I changed in line 19 [2] “-p 22” to “-p 2222”.

Any ideas on how to get it working?
Thanks for your time!

[1] https://github.com/mail-in-a-box/mailinabox/blob/a081d040822ce0f58e0554b6a28e36945cde0275/management/backup.py
[2] “–rsync-options=-e “/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p 22 -i /root/.ssh/id_rsa_miab””,

This question has been asked but never answered. … see this thread for my solution to the problem which may or may not be practical for you.

Thank you for your answer!
I am already doing it like this. :slight_smile:
Maybe this should be more a feature request than a maintenance question. I think it choosing a port for the rsync backup can be useful for a lot of people who want to backup their Mail-in-a-Box to a home computer.

You can push the rsync output to your NAS easily. I am using at home the WD My Cloud Ex2 NAS and the SSH is listening on a different port than the 22. So AFTER opening the 2233 port at the firewall of my router, I’m doing this:

rsync -a -e “ssh -p 2233” /home/user-data/backups/encrypted/ root@xxx.xxx.xxx.xxx:/path/where/to/backup

Don’t forget the encryption key!

You may need to delete the local backup though after the transfer, but this might be a good example for a different cronjob entry.

hello,

i don’t know if this helps but you could just create a ssh config file for the root user on your miab.

/root/.ssh/config

Host hostnameof.your.bkpserver
    Port 2345

this way the rsync job will automatically use the desired port (no need to hack scripts).

3 Likes

Hello everyone
How can I use resync back up?
tell me.
Best regards
Colonel Ajay Ahlawat

Follow the instructions in your admin panel on the
System > Backup Status page
when you select rsync as the choice for where to backup to.

hello ColonelAjayAhlawat
you can try to change the backu.py
or just create a ssh file for rt user.
regards
Cyberops Labs
cyber security courses online
online cyber security training.