Sponsored Content
Full Discussion: Backup Script
Top Forums Shell Programming and Scripting Backup Script Post 303021245 by xCraftRayX on Tuesday 7th of August 2018 08:21:34 AM
Old 08-07-2018
I had installed mysql, mysqldump ncftp etc.
when I use cat command I get this:
Code:
root@mines:~# cat -vet backup.sh
#!/bin/sh^M$
#^M$
### Ustawienia - sciezki do plikM-CM-3w ###^M$
DIRS="/home/ts/ /home/mc/ /home/X"^M$
BACKUP=/home/backup.$$^M$
NOW=$(date +"%d-%m-%Y")^M$
DELDATE=$(date -d "-7 days" +"%d-%m-%Y")^M$
DAY=$(date +"%a")^M$
#^M$
### MySQL ###^M$
MUSER="hiden"^M$
MPASS="hiden"^M$
MHOST="localhost"^M$
MYSQL="$(which mysql)"^M$
MYSQLDUMP="$(which mysqldump)"^M$
GZIP="$(which gzip)"^M$
#^M$
### FTP ###^M$
FTPD="Backup"^M$
FTPU="hiden"^M$
FTPP="hiden"^M$
FTPS="hiden"^M$
NCFTP="$(which ncftpput)"^M$
#^M$
### Start Backup for file system ###^M$
[ ! -d $BACKUP ] && mkdir -p $BACKUP || :^M$
#^M$
  FTPD=$FTPD^M$
  FILE="files-$NOW.zip"^M$
  zip -r $BACKUP/$FILE $DIRS^M$
### Start MySQL Backup ###^M$
# Get all databases name^M$
DBS='$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse "show databases")'^M$
for db in $DBS^M$
do^M$
 FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz^M$
 $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE^M$
done^M$
#^M$
### Dump backup using FTP ###^M$
#Start FTP backup using ncftp^M$
ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF^M$
cd $FTPD^M$
rm -r $DELDATE/*^M$
rm -r $DELDATE^M$
cd^M$
mkdir $FTPD^M$
mkdir $FTPD/$NOW^M$
cd $FTPD/$NOW^M$
lcd $BACKUP^M$
mput *^M$
quit^M$
EOF^M$
#^M$
### Find out if ftp backup failed or not ###^M$
rm -rf $BACKUP^M$

I convert win format to unix using this command and all works: perl -p -e 's/\r$//' < winfile.txt > unixfile.txt

Thanks for all Smilie

Last edited by xCraftRayX; 08-07-2018 at 04:01 PM..
 

10 More Discussions You Might Find Interesting

1. AIX

Backup Script

I'm not sure if this is the place to ask this question but I have a script on an IBM RS6000 that has quit working. I can manually run a backup using SMIT and it appears okay, but not sure about the script. ----------code------------ #!/bin/ksh #set -x echo backup beginning date find... (7 Replies)
Discussion started by: geek4sur
7 Replies

2. UNIX for Dummies Questions & Answers

Backup Script

Hi, My SCO Unixware 7.1.1 box is setup to run an EOD backup script, which is as follows: ---------------------------------------------------------------------- start End-of-day compress $BASE TO /home/compdir write /home/compdir to DATTAPE end ... (0 Replies)
Discussion started by: tayyabq8
0 Replies

3. Shell Programming and Scripting

help in backup script

Hello folks. Good Day! i want to backup /var/www directory backup to another system daily basis incremental backup and weekly full backup. Directory name where it should automatically created like 2010-04-20 i mean via script. Can some one help? (7 Replies)
Discussion started by: learnbash
7 Replies

4. Shell Programming and Scripting

backup script

Hi, I need to write a script that will capture the 8th character on each line (alphanumeric /meta chars) to the 16th character and send to an output file. Any ideas? R, D. (3 Replies)
Discussion started by: Duffs22
3 Replies

5. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

6. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

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)
Discussion started by: javeedkaleem
7 Replies

7. Shell Programming and Scripting

Backup script / Test if script is already running

Hello everyone, I have 2 questions : 1) I have a backup shell script, let's call it backup.sh, that is called every hour as a cron job. As a matter of fact a backup could last more than one hour. It mounts a NAS and then do some rsync on important directories, so really I don't want to... (2 Replies)
Discussion started by: freddie50
2 Replies

8. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

9. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

10. Shell Programming and Scripting

Backup Script

I have write the following script, its execution i got following error: !/bin/sh # # dy='date +%d%b%y' hn="ECTMPROD12" bk='/home/backup' sb=$bk'/'$hn # # cm_d01='tar -czf /home/backup/'$hn'_'$dy'_ofhome.tar.gz /home/oracle/ofhome' # # echo "***** start time of ECTMPROD12 backup full"... (3 Replies)
Discussion started by: rizwan.shaukat
3 Replies
ncftpbatch(1)						      General Commands Manual						     ncftpbatch(1)

NAME
ncftpbatch - Individual batch FTP job processor SYNOPSIS
ncftpbatch -d ncftpbatch -l ncftpbatch -D OPTIONS
Command line flags: -d Begin background processing of FTP jobs in the current user's $HOME/.ncftp/spool directory. This returns immediately, because a daemon process is spawned and ran in the background. -l Lists the contents of the user's job queue. -D This is like -d, except that the process does not become a daemon. DESCRIPTION
This program is responsible for processing background FTP requests. It is normally only run by ncftp and not manually by a human being, however you can run it to manually process the FTP job queue. The jobs are spool files written to a user's $HOME/.ncftp/spool directory and have a special format and file-naming convention (which con- tains when the job is to be run). ncftp runs this program when it needs to, but if the ncftpbatch daemon dies unexpectedly the jobs that are left in the queue will not be processed until another instance of ncftpbatch is run. ncftpget and ncftpput can also be used to submit jobs for batch processing, using those utilities' -b command-line flag. If desired, you can also manually create the spool files although this procedure is not documented here (see the manual page for ncftpspooler for more information on how to do that). DIAGNOSTICS
ncftpbatch writes to its own log file, the $HOME/.ncftp/spool/log file. This file should be examined to determine if any ncftpbatch pro- cesses are actively working on jobs. AUTHOR
Mike Gleason, NcFTP Software (http://www.ncftp.com). SEE ALSO
ncftp(1), ncftpput(1), ncftpget(1). ncftpbatch NcFTP Software ncftpbatch(1)
All times are GMT -4. The time now is 01:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy