I have created a simple backup script that creates .tar.gz of all my important folders and upload it to Google Drive using rclone.
Everything works perfectly fine when I run the script manually. But it seems to be failing when anacron runs it.
I use anacron -fnd to run anacron right away to test if everything is running correctly.
Following are the error I get in my log file
2022/11/28 23:58:03 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
2022/11/28 23:58:03 Failed to create file system for "linuxbackuprclone:Linux-Backup": didn't find section in config file
linuxbackuprclone is the name of my remote in rclone.
Linux-Backup is the name of the folder in Google Drive.
Here is my backup script, it's called backup, located at /home/paramv/Bash-Script, and is named backup
#!/bin/bash set -e backupDirPath="/home/paramv/Linux-Backup" if [ ! -d $backupDirPath ]; then mkdir $backupDirPath fi if [ ! -d "/home/paramv/Bash-Script/Backup-Log" ]; then mkdir Backup-Log fi # Create a log file named after the date the backup was created logFile="/home/paramv/Bash-Script/Backup-Log/$(date).log" logFile=${logFile// /_} touch $logFile # Create tar of dirs to backup echo "Creating backup.tar.gz" >> $logFile # sudo tar -zcf /home/paramv/Linux-Backup/backup.tar.gz -P /home/paramv/Documents/ &>> $logFile if [ $? != 0 ]; then echo "Failed to create backup.tar.gz. Error code = $?" &>> $logFile exit 1 else echo "Completed creating backup.tar.gz" >> $logFile fi # Upload local backup file to the cloud echo "Uploading backup.tar.gz to Google Drive" >> $logFile /usr/bin/rclone copy --update --transfers 30 --checkers 8 --contimeout 60s --timeout 300s --retries 3 --low-level-retries 10 "/home/paramv/Linux-Backup/backup.tar.gz" "linuxbackuprclone:Linux-Backup" &>> $logFile if [ $? != 0 ]; then echo "Failed to upload backup.tar.gz to Google Drive. Error code = $?" &>> $logFile exit 1 else echo "Uploaded backup.tar.gz to Google Drive" >> $logFile fi exit Following is my anacron script located at /etc/cron.weekly, and is named prsnlbackup
#!/bin/sh set -e exec /home/paramv/Bash-Script/backup exit Following is the output of running rclone config.
Current remotes: Name Type ==== ==== linuxbackuprclone drive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> This is what my rclone.conf looks like. It is located at /home/paramv/.config/rclone
[linuxbackuprclone] type = drive scope = drive token = {"omitted to make it readable"} team_drive = I am running Ubuntu 22.04.1 LTS.
Any help will be highly appreciated.
mkdir Backup-Logbut it looks like that needs to bemkdir "$backupDirPath/Backup-Log"or your script needs ensure its working directory is in the right place withcd "$backupDirPath"before creating theBackup-Logdirectory. Probably just a typo in this question rather than in your script, but something to check./root/.config/rclone/rclone.confbut yours is in your users home directory. As a first step I would copy yourclone.conffile to the corresponding location under/rootand troubleshoot from there