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 6934977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:02:15+00:00 2026-05-27T12:02:15+00:00

— file makebackup.sh #!/bin/bash DATE=’date’ mysqldump –all-databases | gzip -9 > /backup/temp_db.gz tar -Pcf

  • 0

— file makebackup.sh

#!/bin/bash
DATE='date'
mysqldump --all-databases | gzip -9 > /backup/temp_db.gz
tar -Pcf /backup/temp_ftp.tar /public_html/
tar -Pcf /backup/temp_backup.tar /home/temp_db.gz /backup/temp_ftp.tar
sleep 60 && /backup/upload.sh $DATE

— file upload.sh

#!/usr/bin/expect -f

# connect via scp
spawn scp /backup/temp_backup.tar root@mybackup.com:/home/backup_$argv.tar
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "mypassword\r"
}
}
interact

Why this does not work, i don’t want to use sleep i need to know when last tar is over and execute file upload.sh. Instead it always executes as soon as last tar file starts.

&& does not do anything even if i remove sleep 60

  • 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-27T12:02:15+00:00Added an answer on May 27, 2026 at 12:02 pm

    As you say ‘Instead it always executes as soon as last tar file starts’, normally that means there is an ‘&’ at the end of the line OR are you sure the tar is really working? Are you looking at an old tar.gz that was created early on? Make sure it is a new tar file that is correct size.
    Edit I’m not saying you have to delete files, just dbl-check that what is being put into the final tar makes sense.

    Are you checking the sizes of input files to your final tar cmd? (/home/temp_db.gz /backup/temp_ftp.tar)? Edit By this I mean, that an uncompressed tar file (temp_ftp.tar) should be just slightly larger than the sum of sizes of all files it contains. If you know that you have 1 Meg of files that compose temp_ftp.tar, and the file is 1.1 Meg, that is good, if it is .5 Meg, then that is bad. (Also consider gziping the whole thing to reduce transmission time to your remote host). Your compressed db file, hard to say, presumably that is working, if the file size is something like 25 bytes, then that indicates an error in creating the file.

    Otherwise what you are saying really seems impossible. It is one of these things, or something else is bollixing things up.

    One way to debug how long the last tar is taking is to wrap the command in two date commands, i.e.

    date
    tar -Pcf /backup/temp_backup.tar /home/temp_db.gz /backup/temp_ftp.tar
    rc=$?
    date
    
    printf "return code from quick tar was ${rc}\n"
    

    Also, per your title, ‘check previous step’, I’ve added capturing the return code from tar and printing the value.

    Again, to reinforce what you know already, in a linux shell script, there is no way (excepting a background job with the ‘&’ char) for one command to start executing before the previous one has completed.

    EDIT ownership and permissions on your files might be screwing things up is ownership and permissions on your files. use \

    ls -l  /backup/temp_backup.tar /home/temp_db.gz /backup/temp_ftp.tar
    

    to confirm that your userID owns the files and and that you can write to them. If you want to, edit your posting to include that information.


    Also, your headline says ‘cron’ : are you capturing all of the possible output of this script to help debug the situation? Turn on shell debugging with set -vx near the top of makebackup.sh. Add debugging output to your tar cmd ‘-v’.

    Capture the cron output of your whole process like

    59 23 31 12 * { /path/to/makebackup.sh 2>&1 ; } > /tmp/makebackup.`/bin/date +\%Y\%m\%d.\%H\%M\%S.trace_log 
    

    And be sure you don’t find any error messages.

    ( Crontab sample, min hr day mon (day-of-week, 0-6 or *) , change date/time to meet your testing needs)


    Your expect script uses ‘\r’, don’t you want ‘\n’ in the Unix/linux environment. If you’re a Windows based server, then you want ‘\r\n’ .

    Edit does the expect script work, have you proved to your satisifaction that files are being copied, are they the same size on the backup site, does the date change?


    If you expect backups to save your systems someday, you have to develop a better understanding of how the whole process should work and if it is working as expected. Depending on your situation and availability of alternate computers, you should schedule a test of your restoring your backups to see if they will really work. As you’re using -P to preserve full-path info, you’ll really need to be careful not to overwrite your working system with old files.

    To summarize my advise, double-check everything.

    I hope this helps.

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

Sidebar

Related Questions

All of my code is on my SVN, but I want some of it
— or — Is there a difference between these? Is one better-supported than the
What is the absolute fastest way to read and write strings from a file
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
I'm including a local class that requests a file from a remote server. This
I've an ASCII file that contains an EM Dash (— or — in HTML).
I am building a site in Wicket. I need to serve a JavaScript file,
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
So to start, I have an array of XML files. These files need to
I'm using some of Firefox's specially-defined values for cursor, in particular -moz-zoom-in -moz-zoom-out -moz-grab

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.