It might help to see the rest of the script... We have no idea what's in 'args' for instance.
Also, have you been editing this file with Microsoft Notepad? That will fill the file with carriage returns that UNIX can't use. Edit it in a UNIX editor like vi or nano instead.
Here's the script. The problem line is in red (error in first post).
Since I'm a n00b, I welcome any security tips in writing this script as well.
Example usage: ./restore.sh 05-20-12 may20 whereby 05-20-12 is a datestamp of the DB file (i.e. backup.05-20-12.sql) and may20 is the database to-be-created in MySQL (that will hold the restored data).
I've been using TextEdit on my Mac (plaintext format, not rich-text) and copying the script into the file via the nano command. Would that be causing a problem, even if TextEdit is in plain-text editing mode?
That 'args' array is pointless -- especially since you're using /bin/sh, not /bin/bash, and hence are not even guaranteed to have arrays. Just use the already-existing special variables to do that $1 $2 (Note $0 is not the first in the list, $0 is the name the script was called by).
copy-pasting from texedit might cause problems for all I know. It may certainly destroy your formatting, especially tabs. Mostly I see no point doing that in the first place, nano's a perfectly serviceable text editor on its own.
Thanks! Got it. What happened was... when I pasted the text in from TextEdit into the Nano editor, certain lines did indeed get jumbled. Just had to put them all back on the same line. Simple fix!
Thanks for the note on args, I'll be sure to change that.
Hi All,
The MySQL & OpenLDAP database on my Debian are very lightly updated.
Usually I tar everything on / including the databases.
The restore works OK on another machine.
I want to know whether its safe to do file level backup of databases like this ?
Do the MySQL & OpenLDAP databases... (0 Replies)
Hello all!
First posting here! So be patient with me.
I made a clean install with MacOS 10.8 and need to restore my Databases from my external backup drive. Apparently it is not possible, to create the MySQL user and password as before, and simply drag the databases from... (12 Replies)
Hello
I have a production mysql server and archive server, unfortunitly its not possible to setup repliacation between the two, the reason is that the archive server is using some fancy storage engine which doesn't allow mysql replication.
I'm trying to write a script using perl that does... (1 Reply)
Hi all
i am struggling in creating a restore of env files while doing applications clone.
the first file i created for copying the important configurations file
which is running perfect
now for reverting the changes i mean when i am restoring these files to its original places
i have to do... (7 Replies)
Hi, im trying to make a script that backups mysql databases but apparently I am having trouble with the variables, or simply something I am missing.
Would appreciate any help, here is the script
#!/usr/bin/perl -w
use strict;
require File::Spec;
#VARIABLES
my $databasename =... (4 Replies)
Hi All,
Thanks in Advance!!
How to backup a particular Databases..through Bash script!!
For example i have 6 databases;
Anish
linux
Software
Questions
Rhce
Google
these are the databases i have from that i want to take "Anish" and "questions" database backup regularly.... (4 Replies)
I am trying to restore opt on my server.
my issue is, all the partitions are saved into the same back up tape.
what is the exact command to just restore /opt for example, supposing c0t0d0s7 is the partition for /opt
---------- Post updated at 01:16 PM ---------- Previous update was at... (7 Replies)