Help with Backup Shell Script

Dear friends, I need your help.

I need to create a bash script which can loop through $source_dir once a month, and find the backup of the last day of a given month for each of the 2 file types, as can be seen below.

Assume that source_dir="/backup/daily"
Assume that dest_dir="/backup/monthly"

Assume that the 2 types of files are:
this-file-.gz
that-doc-
.tar.gz
...as can be seen below.

Type 1:

  • this-file-other-week.gz
  • ............
  • ............
  • this-file-other-day.gz
  • this-file-yesterday.gz
  • this-file-today.gz

Type 2:

  • that-doc-other-week.tar.gz
  • ............
  • ............
  • that-doc-other-day.tar.gz
  • that-doc-yesterday.tar.gz
  • that-doc-today.tar.gz

The script should then pick the 2 files (separately) which have been backed up at the end of the month, and backup each one of them in $dest_dir with such names as:

  • this-file-monthly.gz
  • that-doc-monthly.tar.gz

I am having trouble with this particular component of the script and any help is highly appreciate.

Thank you

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.