laurent22 / rsync-time-backup

Time Machine style backup with rsync.
3.38k stars 446 forks source link

grep warning "stray \ before :" in fn_parse_ssh() and df / warning " No such file or directory" in fn_df_t_src() #270

Closed shmilee closed 6 days ago

shmilee commented 1 week ago
[$] grep --version                                           :) 0
grep (GNU grep) 3.11

[$] rsync_tmbackup-old.sh "/" /some/backup/place
grep: warning: stray \ before :
grep: warning: stray \ before :
df: '': No such file or directory
............
  1. grep and : https://github.com/laurent22/rsync-time-backup/blob/7af3df3644371c7f4f792b617147f0be6da63db9/rsync_tmbackup.sh#L178
@@ -175,7 +175,7 @@

 fn_parse_ssh() {
    # To keep compatibility with bash version < 3, we use grep
-   if echo "$DEST_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$'
+   if echo "$DEST_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+:.+$'
    then
        SSH_USER=$(echo "$DEST_FOLDER" | sed -E  's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/')
        SSH_HOST=$(echo "$DEST_FOLDER" | sed -E  's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/')
@@ -186,7 +186,7 @@
            SSH_CMD="ssh -p $SSH_PORT ${SSH_USER}@${SSH_HOST}"
        fi
        SSH_DEST_FOLDER_PREFIX="${SSH_USER}@${SSH_HOST}:"
-   elif echo "$SRC_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$'
+   elif echo "$SRC_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+:.+$'
    then
        SSH_USER=$(echo "$SRC_FOLDER" | sed -E  's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/')
        SSH_HOST=$(echo "$SRC_FOLDER" | sed -E  's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/')
  1. df -T '', when src is "/"

https://github.com/laurent22/rsync-time-backup/blob/7af3df3644371c7f4f792b617147f0be6da63db9/rsync_tmbackup.sh#L255 https://github.com/laurent22/rsync-time-backup/blob/7af3df3644371c7f4f792b617147f0be6da63db9/rsync_tmbackup.sh#L353-L356 https://github.com/laurent22/rsync-time-backup/blob/7af3df3644371c7f4f792b617147f0be6da63db9/rsync_tmbackup.sh#L379

@@ -252,11 +252,11 @@
 }

 fn_df_t_src() {
-   fn_run_cmd_src "df -T '${1}'"
+   fn_run_cmd_src "df -T '${1}/'"
 }

 fn_df_t() {
-   fn_run_cmd "df -T '${1}'"
+   fn_run_cmd "df -T '${1}/'"
 }
shmilee commented 6 days ago

mv to https://github.com/shmilee/arch-time-backup Implement some new features and fix these issues by myself. Close this. Thanks to laurent22 's script, that helps me a lot!