Quote:
Originally Posted by noteleks
I have the following script I did using a website that explained it:
Code:
#!bin/bash
find "/obsbackupfolder" -type f -mtime +5 -exec rm {} \;
# Compress the folder with foldername + date and take backup
filename="backup_ `date +%d`_`date +%m`_`date +%Y`.tar";
# Create compressed file using tar and move to backup folder
tar cvf /obsbackupfolder/backup.tar /home/mintObsidianValults/
# Go to the backup folder location
cd /obsbackupfolder
# List the content
ls
# Show the size of the folder
du -sh
|
The fact they explained it is no help to anyone here.
Your script creates a variable
filename which includes the date and time, but it never actually uses that variable to create a file with that name.
Then you do not say what that script's name is so it is ambiguous what your cron job should actually be doing, even if it were written correctly... but it isn't...
Quote:
Originally Posted by noteleks
In my CronJob
I have the following:
Code:
0 16 * * * .backup.sh"
0 16 * * * ./remove-backup.sh
I get the backup.tar; but do not get a date or time or both on it. Thank you for any help.
I also checked the backup.tar and all the files are in there.
|
It is surprising that you produce any backup file at all, but we probably do not have the full picture in the above example.
The first line includes an unmatched double-quote character which is certainly an error.
Both lines use relative file paths which are generally not going to work in a cron spec file. Cron does not run with the same environment as a login shell, so paths like
./remove-backup.sh will be meaningless to it. Always use absolute paths to your scripts in the crontab, or cron spec file.
See if you can fix those problems and if you cannot get it to work please include the actual name of the script and a few more details such as whether the cron runs as root or a normal user and the absolute paths to the scripts.
Good luck!