0

link for the file showing difference between two archives

As you can see the difference between the size of files.

Backup of dec-12 was taken through cron while backup of dec-13 was taken by running the script manually.

And I haven't worked or added any new file between these two days. There were no changes in the files.

Script of Backup:-


#!/bin/bash 
#typically the first line of the bash scripts

BACKUPTIME=date +%b-%d-%y #get the current date DESTINATION=/home2/wedevelo/backup/backup-$BACKUPTIME.tar.gz TESTDESTINATION=/home2/wedevelo/backup/test/backup-$BACKUPTIME.tar.gz SOURCEFOLDER=/home2/wedevelo/public_html/mdjewellers/ TESTSOURCEFOLDER=/home2/wedevelo/public_html/test/mdjewellers/

tar -zcpf $DESTINATION $SOURCEFOLDER #create the backup tar -zcpf $TESTDESTINATION $TESTSOURCEFOLDER

Here is cron command.

MAILTO="info@wedevelop.in"
5 0 * * * /bin/bash /home2/wedevelo/backup_script.sh

I don't know what os is this as I'm using shared hosting of Bluehost.

  • 4
    You are showing us that the backup for Dec 13 is larger than the backup for Dec 12, which is normal if you did more work between the two backups. What makes you think it is wrong? Please [edit] your question and explain how you are checking the files. Also tell us what operating system you are using, how you are setting up the crontab and which crontab you are using. – terdon Dec 17 '20 at 13:40
  • 2
    Please don't use screenshots if you can use text, e.g. show the output of ls -l file 1 file2 The file names in the screenshot don't match the script. The file size doesn't show what is different. List the contents of the backup files and check what is different. You can do this for example with commands like these: tar tzf backup-Dec-12-20.tar.gz > files12.txt, tar tzf backup-Dec-13-20.tar.gz > files13.txt, diff -uw files12.txt files13.txt Show the output in the question. I suggest to save the error output to a file, e.g. tar -zcpf $DESTINATION $SOURCEFOLDER 2> /path/to/a_file. – Bodo Dec 17 '20 at 13:50

1 Answers1

0

omit the final slash of the SOURCEFOLDER – the issue is with globbing, which is different depending on the ENViroment! ;-)

EDIT: It should've worked; there are a number of references here that point to the same cause but offer different approaches to solving the issue – meaning actually providing the same environment for the script to run in. It is your users CRONTAB, or is it root's CRONTAB? In short: add . $HOME/.profile before your script execution in the crontab line like Arcege explained. Or go one of the routes explained in this serverfault answer.

flowtron
  • 356
  • I tried that but the results are still same – Akash Maurya Dec 20 '20 at 06:09
  • that is curious, it's been the solution for me oh so many times. I've added some cross-linkage to other answers/solutions – you may also try to narrow down the issue by having a script do various forms of listings .. once by hand on the command line, once by script and once by crontab triggered script. with trailing slashes and without and anything else you can think of to find out what and why it is different. Execute whoami, pwd and envinside the script sending output to some logfile ( env >> /tmp/currentlog 2>&1) – flowtron Dec 21 '20 at 08:51