Hey everyone! I've been wrestling with a bash script on my Synology for the past 10 hours, mostly guided by chatGPT. Unfortunately, while the script worked initially, it eventually started downloading way too many files, leaving me frustrated. I want it to run every 6 hours and shut itself down afterwards to avoid issues with Synology's task scheduler. I can't access crontab because I usually have SSH disabled, and the DSM GUI limits my options.
My goal is to create an incremental backup of files from an FTP server, specifically from the folder /virtual, which contains tons of tiny files across many subfolders. Here's the breakdown of what I want:
1. First, create a full backup of the /virtual folder.
2. On subsequent runs, I need to copy the previous backup into a new folder that includes the current timestamp.
3. Finally, connect to the FTP and download only the new or changed folders and files.
However, my latest attempts only confuse lftp, leading to redundant downloads. I've included my latest bash script below. I'm pretty stuck, and I'm only able to use FTP - no SFTP or rsync. Any guidance would be greatly appreciated!
3 Answers
Try adding `set -xv` at the start of your script. It'll help you debug by showing exactly where it's having issues. Start with simpler components and build back up, making copies of your script after each change to track what works and what doesn't!
Have you considered looking into alternative protocols? FTP is pretty outdated; if at all possible, switching to SFTP over SSH with rsync could save you a lot of trouble! You might find it more reliable.
For future reference, try posting your scripts on a pastebin or Gist link. Makes it way easier to read! Also, keep in mind that Synology has some custom tweaks, so maybe you could leverage Docker to run your backup/sync job in a container.
Great tip! Also, consider using the `script` command to record the output, which can help in diagnosing the issues. If the AI-generated script is buggy, you could try getting help from other AI tools too.