rdiff-backup files from Mac to Ubuntu - zsh:1: command not found: rdiff-backup

I was using rdiff-backup to backup files from my Mac Book Pro 2011 (running High Sierra OS) to my Ububtu server (20.04.5 LTS)...



This was working sucessfully, until I replaced the Mac Book Pro 2011 with a Mac Book Pro M1 (running Ventura OS).


Now when I run my backup script, I get the error "zsh:1: command not found: rdiff-backup"


On the old Mac Book Pro 2011, I had to add the following line to ~/.bashrc...


PATH=/usr/local/bin:$PATH


It seems the new Mac M1 uses zsh now instead of bash and I am not sure whether I need to do something similar ?


What I cant understand is when I SSH from Ubuntu server to the Mac, the rdiff-backup command is found (here it reports the version as 2.0.5)...



Yet when I run the backup script from Ubuntu server (which I assume effectively does the same thing) the rdiff-backup command cannot be found...



The Mac has rdiff-backup version 2.0.5 which I installed using Mac ports, the Ubuntu server has rdiff-backup version 2.0.0.


Below is the script (rdiff-macm1-john.sh) I run from Ubuntu server...


#!/bin/bash

# Use this script to perform a backup of Mac user to the server via SSH 

# Source: /Users/macbookpro

# Destination: /media/storage/Backup/Mac/macbookpro


rdiff-backup -v9 --print-statistics \

--exclude-special-files \

--exclude ignorecase:'**.ini' \

--exclude ignorecase:'**.DS_Store' \

--exclude ignorecase:'**\$RECYCLE.BIN' \

--exclude ignorecase:'**.AppleDouble' \

--exclude ignorecase:'**.localized' \

--exclude /Users/macbookpro/Documents/Microsoft\ User\ Data \

--exclude /Users/macbookpro/Documents/Parallels \

--exclude /Users/macbookpro/Downloads/svn \

--include /Users/macbookpro/Desktop \

--include /Users/macbookpro/Documents \

--include /Users/macbookpro/Downloads \

--include /Users/macbookpro/Movies \

--include /Users/macbookpro/Music \

--include /Users/macbookpro/Pictures \

--exclude '**' macbookpro@johns-mbp.fritz.box::/Users/macbookpro \

/media/storage/Backup/Mac/macbookpro

MacBook Pro

Posted on Dec 26, 2022 10:00 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 27, 2022 8:08 AM

At last I got it working !


I created the profile .zshenv with the following path...


PATH=/opt/local/bin:$PATH


and now the rdiff-backup command works.


What a palava !


Thanks all for taking the time to help :)

8 replies

Dec 27, 2022 8:00 AM in response to sky_rat

So from Linux if I run the following to connect to the Mac using SSH...


ssh macbookpro@johns-mbp.fritz.box



and then once connected run...


rdiff-backup -V 


it works and reports 2.0.5.


But if I run...


ssh johnlintern@johns-mbp.fritz.box rdiff-backup -V


I get the error...


zsh:1: command not found: rdiff-backup


However, if I run...


ssh johnlintern@johns-mbp.fritz.box /opt/local/bin/rdiff-backup


it works and reports 2.0.5.


So it has to be a path setting, but I cannot figure out how to fix it having tried both .zshprofile with...


export PATH="${PATH}:/opt/local/bin"


and .zshrc with...


export PATH="${PATH}:/opt/local/bin"


Dec 26, 2022 10:34 AM in response to sky_rat

Zsh does not read the Bash dot files and requires its own (e.g. $HOME/.zshrc). This file does not exist until you create it and you may need the same, or revised PATH configuration as was done in your prior Bash dotfiles.


The rdiff-backup is not distributed with macOS and is installed via a package manager (e.g. homebrew). On Intel machines, homebrew installs into /usr/local, and on M1/M2 Macs, it uses /opt/homebrew and compiles packages as native arm64e binaries. Although the Intel-built rdiff-backup binary may work on Monterey/Ventura as an X86_64 binary using Rosetta2, it might be a good idea to remove and reinstall it so it is compiled for the current M1/M2 architecture. Also, if you are using /opt/homebrew you will need to add this to your PATH:


export PATH="${PATH}:/opt/homebrew/bin"


So that Zsh can help you locate the rdiff-backup binary. A /usr/local/bin path is included in ${PATH}.

Dec 27, 2022 1:54 AM in response to VikingOSX


Thanks VikingOSX


I tried running the command using both -h and --help but it did not recognise either option...


/opt/homebrew/bin/rdiff-backup --help
Fatal Error: Bad commandline options: option --help not recognized
See the rdiff-backup manual page for more information.


/opt/homebrew/bin/rdiff-backup -h
Fatal Error: Bad commandline options: option -h not recognized
See the rdiff-backup manual page for more information.


According to the website the options are -h or --help...


https://rdiff-backup.net/rdiff-backup.1.html


I tried the other command you mentioned but it did not find the command brew (which is strange because I installed rdiff-backup using brew):


brew deps --tree --installed rdiff-backup
zsh: command not found: brew


I remember now why I used Mac Ports to install rdiff-backup, after initially using homebrew to install rdiff-backup.


It was because the home brew version of rdiff-backup was showing DEV, whereas I needed the same version thats on Ubuntu which is 2.0.0...


/opt/homebrew/bin/rdiff-backup -V
rdiff-backup DEV


/opt/local/bin/rdiff-backup -V
rdiff-backup 2.0.5


Correct, I am performing SSH from the Linux side to initiate the backup


Dec 27, 2022 6:19 AM in response to sky_rat

I know that the ~/.zshrc dotfile is being read from the Mac side when one launches a new Terminal window, or subshell, but it would appear your macOS PATH is not being read when using SSH from Linux. That is why I suggested the ~/.zshprofile with the PATH addition of /opt/homebrew/bin in it as that is where the brew command lives too. You may have to perform the following immediately to set the correct PATH when you receive the Mac prompt during the SSH connection:


source ~/.zshprofile


The current version of rdiff-backup for macOS and Linux is now 2.0.5.

Dec 26, 2022 11:10 AM in response to VikingOSX

Many thanks VikingOSX


rdiff-backup was not recognised when I typed it into Mac terminal, so I had to install it.


I initially installed rdiff-backup using brew (brew install rdiff-backup), but after installation when I tried to run the rdiff-backup command it was not recognised.


So I then installed rdiff-backup using Mac Ports (sudo port install rdiff-backup.... after installing the Mac Ports package). This took a very long time (20 to 30 min!) and it also installed lots of other packages.


Therefore I currently have the homebrew version of rdiff-backup installed...




And the Mac Port version of rdiff-backup installed...





I found the version of rdiff-backup being used by typing the following in terminal...


which rdiff-backup


and it gave me the following path...


/opt/local/bin/rdiff-backup


So I created the .zshrc file in $HOME/. and used the path above...


export PATH="${PATH}:/opt/local/bin"


Then to refresh the profile I used...


source ~/.zshrc   


However, I still get the same error when running the backup script from Ubuntu (i.e. zsh:1: command not found: rdiff-backup)


PS. I don't like how long it took to install the Mac Ports version of rdiff-backup and all the other packages it installed (makes me nervous). Ideally I would like to remove the Mac Ports version and use the homebrew version, but I dont know how to do this. Though the first step is to get rdiff-backup working from my server !

Dec 26, 2022 1:16 PM in response to sky_rat

Check with Macports on how to remove their packages and then their installation.


Can you run the following in the Terminal (assuming it has a command-line help feature with either a single or double '-' before help or there is the rdiff-backup website for further clarification?


/opt/homebrew/bin/rdiff-backup --help


if you run the following from the Terminal, you can see a tree diagram of rdiff-backup dependencies without installing it.


brew deps --tree --installed rdiff-backup


Are you performing SSH from the Linux side to initiate the backup? You may need a $HOME/.zshprofile as well with your PATH showing /opt/homebrew/bin in it. I don't do ssh between computers so uncertain if the $HOME/.zshrc file is ignored in an SSH session.



Dec 27, 2022 7:34 AM in response to VikingOSX

Thansk VikingOSX, I tried that but it made no difference.


I created ~/.zshprofile on the Mac and put the following path...


export PATH="${PATH}:/opt/local/bin"


Note that I used the Mac Ports path (/opt/local/bin) instead of the Homebrew path (/opt/homebrew/bin), because the rdiff-backup install from Mac Ports shows the version as 2.0.5, whereas the rdiff-backup install from the homebrew path shows the version as DEV (as mentioned in my previous post).


I then refreshed using...


source ~/.zshprofile


I dont understand how when I SSH from Linux to the Mac using...


ssh macbookpro@johns-mbp.fritz.box



then run the command...


rdiff-backup -V 


the command it works (it shows version 2.0.5).


Yet when I run the script where rdiff-backup calls this command...


ssh -C macbookpro@johns-mbp.fritz.box rdiff-backup --server


it says...


zsh:1: command not found: rdiff-backup


Why is it different ?


Why can I SSH from Linux to the Mac the rdiff-backup command works, yet when I run the script it doesn't ?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

rdiff-backup files from Mac to Ubuntu - zsh:1: command not found: rdiff-backup

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.