2

I wrote three bash files:

  1. incremental_backup
  2. full_backup
  3. execution

Now I want another bash script do the following :

if (date is the start of month 1/-/----)
then     
    invoke `full_back_up`
else
    invoke `incremental_backup`

How can I write this script?

user unknown
  • 151
  • 2
  • 7
Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54

2 Answers2

14

Don't do this. Instead use two separate cron jobs to invoke your tasks.

15 5 1 * * scripts/full_back_up
15 5 2-31 * * scripts/incremental_backup
Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
  • I do this to mark backups as "yearly", "monthly", "daily" in file name and then I delete with `find` command. Is this wrong for some reason? – Kamil Dec 14 '22 at 02:10
9

Try

if [ `date +%d` != "01" ] 
then
    incremental_backup
else
    full_backup
fi
user9517
  • 115,471
  • 20
  • 215
  • 297
  • Your answer's the same as mine, and earlier, so I deleted mine. You might want to de-capitalise the "I" in your fisrt "if", though! – MadHatter Nov 03 '10 at 10:02
  • You should leave your answer up. There are quite a lot of duplicate answers on the site. It all adds to the community. – user9517 Nov 03 '10 at 10:14