UserScripts: Need help for my Backups with rsync incremental script by mgutt


Recommended Posts

Hi there, I use the Backup Script by mgutt for all my backups. Now its a little bit anoying to visit every backup folder to check the log file. I want to save all the log files to one share, where i can access them directly. I am not that good at bash scripting so can anybody help me please? I found this in  the end of the script and i tried many things to move the file to a share. But it did not work.

 



 

  # move log file to destination
  log_path=$(rsync --dry-run --itemize-changes --include=".$new_backup/" --include="$new_backup/" --exclude="*" --recursive "$dst_path/" "$empty_dir" | cut -d " " -f 2)
  [[ $log_path ]] && rsync "${dryrun[@]}" --remove-source-files "$log_file" "$dst_path/$log_path/$new_backup.log"
  [[ -f "$log_file" ]] && rm "$log_file"

done

 

 

 

I asked in the Rsync Incremental Thread but no response. I wrote a PN to mgutt but he did not answer to this time. So i try it here again.

 

Thank you for your help!

Link to comment
  • 3 weeks later...

Hi Naitor

 

If you still need help?
I have a lot of fun to write scripts and therefore offer my help.. :)

 

However, I would need a larger section like this.
But there are some errors here.. ^^

 

Maybe this will help you orientate yourself:

# Sample variables (ensure these variables are correctly)
dst_path="/path/to/destination" # Destination directory
log_file="/path/to/logfile.log" # Path to the log file
new_backup="backup-$(date +%Y-%m-%d)" # New backup folder, e.g., backup-2023-04-01

# Create the new backup directory in the destination directory if it does not exist
mkdir -p "$dst_path/$new_backup"

# Check if the log file exists, and then move it using rsync
if [[ -f "$log_file" ]]; then
  # Use rsync to move the log file to the new backup directory and then delete the original
  rsync -av --remove-source-files "$log_file" "$dst_path/$new_backup/"

  # Check if rsync worked correctly
  if [ $? -eq 0 ]; then
    echo "Log file has been moved to: $dst_path/$new_backup/$(basename "$log_file")"
  else
    echo "Failed to move the log file."
  fi
else
  echo "Log file does not exist: $log_file"
fi
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.