0

Good evening. I have a new mac and a backup script that I found and adapted from the web does not work anymore (it works on my old mac).

it is a simple script for backing up the whole home dir on an external drive

    #!/bin/bash
    
    # A script to perform incremental backups using rsync
    
    set -o errexit
    set -o nounset
    set -o pipefail
    
    readonly SOURCE_DIR="/Users/username"
    readonly BACKUP_DIR="link to folder in external drive"
    readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
    readonly BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
    readonly LATEST_LINK="${BACKUP_DIR}/latest"
    
    mkdir -p "${BACKUP_DIR}"
    
    rsync -av --delete \
      "${SOURCE_DIR}/" \
      --link-dest "${LATEST_LINK}" \
      --exclude=".cache" \
      "${BACKUP_PATH}"
    
    rm -rf "${LATEST_LINK}"
    ln -s "${BACKUP_PATH}" "${LATEST_LINK}"

The first part of the error output is

: command not found
: command not found
: command not found
: invalid option namet: errexit
: invalid option namet: nounset
: invalid option namet: pipefail
: command not found
: command not found
: command not found
sending incremental file list

echo $path output is

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin

but sudo nano /etc/paths feedback is

/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin
  • From the error messages, your script somehow got converted to DOS/Windows format, which causes all sorts of trouble; you need to convert it back to unix format. See ["Are shell scripts sensitive to encoding and line endings?"](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – Gordon Davisson Jan 02 '23 at 17:43
  • Yes. I really can't understand the whole thing but it made it!. Downloaded dos2unix and executed dos2unix filename.sh – InflatableGull Jan 02 '23 at 20:12
  • I saw it thanks. Useful for understanding what's behind, then going for dos2unix – InflatableGull Jan 04 '23 at 09:03

0 Answers0