LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-24-2006, 01:05 PM   #1
scotchboy
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
Exclamation Backup script problems


I am having a problem with my backup script. I am new to this. I am running Suse Linux and using rsync to backup some of my servers to this server. I want to use cron to run a bigger script than this, but I have a problem with the script. When I run the script, it works the first time, but all the directories that have been moved are named (for example):
backup.20%0d
rather than:
backup.20

I need to know why it puts the %0d after the directory name.

Below is the script, why is this happening? Please help.

-----------------------------------------------
rm -rf /backups/test/vol1/backup.20
mv /backups/test/vol1/backup.19 /backups/test/vol1/backup.20
mv /backups/test/vol1/backup.18 /backups/test/vol1/backup.19
mv /backups/test/vol1/backup.17 /backups/test/vol1/backup.18
mv /backups/test/vol1/backup.16 /backups/test/vol1/backup.17
mv /backups/test/vol1/backup.15 /backups/test/vol1/backup.16
mv /backups/test/vol1/backup.14 /backups/test/vol1/backup.15
mv /backups/test/vol1/backup.13 /backups/test/vol1/backup.14
mv /backups/test/vol1/backup.12 /backups/test/vol1/backup.13
mv /backups/test/vol1/backup.11 /backups/test/vol1/backup.12
mv /backups/test/vol1/backup.10 /backups/test/vol1/backup.11
mv /backups/test/vol1/backup.09 /backups/test/vol1/backup.10
mv /backups/test/vol1/backup.08 /backups/test/vol1/backup.09
mv /backups/test/vol1/backup.07 /backups/test/vol1/backup.08
mv /backups/test/vol1/backup.06 /backups/test/vol1/backup.07
mv /backups/test/vol1/backup.05 /backups/test/vol1/backup.06
mv /backups/test/vol1/backup.04 /backups/test/vol1/backup.05
mv /backups/test/vol1/backup.03 /backups/test/vol1/backup.04
mv /backups/test/vol1/backup.02 /backups/test/vol1/backup.03
mv /backups/test/vol1/backup.01 /backups/test/vol1/backup.02
mkdir /backups/test/vol1/backup.01
cp -al /backups/test/vol1R/current/* /backups/test/vol1/backup.01
-----------------------------------------------------

Last edited by scotchboy; 07-24-2006 at 01:35 PM.
 
Old 07-24-2006, 07:09 PM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Hmm, interesting. Not sure why it would append that. But, wow, what a script . Why not tar and gzip the backups? That way, it doesn't take up as much space. Something like this:

Code:
#!/bin/bash

DATE=`date +%Y%m%d`
DIR="/backups/test/vol1R/current/"
BACKUPDIR="/backups/test/vol1/"

tar czvf - ${DIR} > ${BACKUPDIR}backup${DATE}.tar.gz
By appending the date next to the backup, you have a way of knowing when the backup was performed.

-twantrd

Last edited by twantrd; 07-24-2006 at 07:13 PM.
 
Old 07-24-2006, 07:33 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
This backup script wasn't uploaded from a windows machine or anything, was it? %0d, taken as hex for an ASCII character, is the \r character used in windows line endings.
 
Old 07-24-2006, 08:15 PM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
you can remove the \r characters of your script by doing

Code:
cat script | sed s/\\r//g > .tmp
cat .tmp > script
rm .tmp
 
Old 07-25-2006, 09:32 AM   #5
scotchboy
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the help

I appreciate the help. What I did to fix it was retype everything on the linux box. I had originally typed the text on a windows pc and when I got it to the linux box, copied and pasted the text into my script file. I still don't know why that wouldn't work, but its done. Thanks Steve
 
Old 07-25-2006, 04:47 PM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
It just got an extra (nonprintable) character tacked onto the end of each line. Glad you got it working now.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup Script Help Canni Programming 8 06-15-2006 10:19 AM
Using CP in my backup script. Echo Kilo Programming 6 06-01-2005 08:43 AM
backup script nitaish Linux - General 1 04-22-2005 11:31 AM
Need a backup script enygma Linux - General 5 11-04-2004 03:49 PM
Script Backup Buto Linux - General 2 10-18-2004 05:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration