Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5965501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:38:22+00:00 2026-05-22T19:38:22+00:00

Hey all, I made a backup script and it will save the file but

  • 0

Hey all, I made a backup script and it will save the file but instead of the file being named 01_files.tar.gz or 01_databases.tar.gz all I get is a .tar.gz and then the rest of the script cannot work properly.

Here is how I set the numbers I needs in my filename:

# Date Variables
DAY_OF_YEAR=$(date '+%j')
DAY_OF_MONTH=$(date '+%d')
DAY_OF_WEEK_RAW=$(date '+%w')
DAY_OF_WEEK=$((DAY_OF_WEEK_RAW + 1))
MONTH=$(date '+%m')
YEAR=$(date '+%Y')

Here is where I am making my folders:

# Make Weekly Folder
mkdir tmp/weekly
echo 'Made weekly folder...'

# Make Folder For Current Year
mkdir tmp/$YEAR
echo 'Made folder for current year...'

# Make Folder For Current Month
mkdir tmp/$YEAR/$MONTH
echo 'Made folder for current month...'

# Make Biannual Folder For Current Year
mkdir tmp/$YEAR/biannual
echo 'Made biannual folder for current year...'

# Make The Weekly Backup
tar -zcvf tmp/weekly/$DAY_OF_WEEK_files.tar.gz $SOURCE
mysqldump -Av -u $DATABASE_USER -p$DATABASE_PASSWORD > $DAY_OF_WEEK.sql
tar -zcvf tmp/weekly/$DAY_OF_WEEK_databases.tar.gz $SOURCE
rm -rf $DAY_OF_WEEK.sql
echo 'Made weekly backup...'

However like I said I am ending up with .tar.gz instead of a proper name like 01_files.tar.gz and 01_databases.tar.gz so the folders are not being properly placed in the correct folders and the rest of the script doesn’t work. Am I doing a data type wrong?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:38:22+00:00Added an answer on May 22, 2026 at 7:38 pm

    Try it like this

    tar -zcvf "tmp/weekly/${DAY_OF_WEEK}_files.tar.gz" $SOURCE
    

    Otherwise the shell will go looking for a variable called DAY_OF_WEEK_files. Same applies to DAY_OF_WEEK_databases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, i have made a simple form that mimiks the jQuery GROWL effect
Hey all, I've made a facebook application for a contest, which allows users to
Hey all- I have looked this up on here and Google but none of
hey all, I have made a socket server in C# for a flash game
Hey I made a project where multiple UIImageView is randomly created and all of
Hey there I've made a recursive permutation function for class, but I output is
Hey all basically I'm trying to save an array of custom objects, it saves
Hey all i am trying to delete a key from the registery but i
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.