My goal is to back up specified folders as a tar.bz2 archive, upload them to my Google Drive, then delete the archive on a schedule. Idealy, I would have 2 backed up files; 1 that is uploaded to the Google drive as the current backup and another new one, so there are always 2 backup files on my local system, but one file that is uploaded to Google Drive. The oldest backup should be deleted when the newest is created. I’d love to create a script for this, but my knowledge is limited to what I’ve done so far, which is creating 3 cronjobs:
thanks! this waits for each step to complete successfully before going to the next?
also, does rclone only replace the current backup if its 100% uploaded?
i ask because im afraid if a disaster happens and my server dies mid upload, i will have no backup and a corrupt halfway uploaded file
also weirdly enough, when i tar normally without the script, it uses the .tarignore i’ve set but the script ignores the .tarignore in /home/bots/.tarignore
Which will cause the script to exit if any of the actions fail. Note that the moves will fail unless there is a file to move, so you might want to create a dummy one first!
That depends on the backend, but with drive that is the case.
It might depend on where you start the tar command so you might want to insert a cd /somewhere in before the tar command.
thank you!
here’s the error i get
2018/10/02 22:47:53 ERROR : Google drive root ‘apps/discord/backups/bots.tar.bz2.1’: Server side directory move failed: directory not found
2018/10/02 22:47:53 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
2018/10/02 22:47:53 ERROR : Google drive root ‘apps/discord/backups/bots.tar.bz2.1’: Server side directory move failed: directory not found
2018/10/02 22:47:53 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
2018/10/02 22:47:53 ERROR : Google drive root ‘apps/discord/backups/bots.tar.bz2.1’: Server side directory move failed: directory not found
2018/10/02 22:47:53 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
2018/10/02 22:47:53 Failed to move: directory not found
It would do as that is when all the old versions have been created.
I can see from your screenshot I made a mistake with the move commands
These should be moveto commands not move otherwise it will move them into directories with those names. You’ll want to move the bots.tar.bz2.2 and bots.tar.bz2.1 out the way first.