Rsync script and backup problems.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsync script and backup problems.
# 1  
Old 11-10-2011
Rsync script and backup problems.

Hello everybody

I'm triing since few days to do this. So sorry if my question looks stupide, but i've tried.

I have to get picture from a folder (who is updated automaticly and with subfolder) with theirs extensions (i'm ok on that) and this files have to me copied in a folder where a website base on php will edit them (rename and creating of and xml file).
The problem is because of the rename function of the script when I do again the copy, it put it back and the script rename it... I've tried rsync with --backup with a folder --backup-dir define, but it's still doesn't work, it's still sending file in backup folder desite their presence in the incremental folder.

Here is my code. You can laugh on them, i'm not a pro shell script coder.

Code:
#!/bin/bash
find  '/home/name/picture' -name '*.jpg' | while read FILE ; do rsync --backup  --backup-dir=incremental --suffix=.old  "$FILE" /var/www/media ; done
wget --spider 'http://myscript.php' ; 
#exit 0

When I lauch just the find and rsync functions, it doesn't put all my files in the incremental folders (and the extensions). I have to run the functions twice to get all files in incremental folder. This the command.
Code:
find  '/home/name/picture' -name '*.jpg' | while read FILE ; do rsync --backup  --backup-dir=incremental --suffix=.old  "$FILE" /var/www/media ; done

Thank in advance for your help.


PS; A little more thing, would be to replace '.' with a 'space' just after the *.jpeg copy. My php script have some problem to define file with with comma because of the extension. I'm finking about a command with 'find' like I like just below with a 'sed' function? It's good?Image
# 2  
Old 11-11-2011
you can try this..
Code:
find ! -wholename /home/name/picture -name '*.jpg'|xargs -I '{}' rsync -abR --backup-dir=incremental --suffix=.old '{}' /var/www/media/

# 3  
Old 11-11-2011
Thanks. I'm gonna try now.

---------- Post updated at 01:41 PM ---------- Previous update was at 01:02 PM ----------

I miss something, I have to grab image from all folder and sub folder to one folders. I tried your script and it keep the directory.
I get also this for xargs
Code:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

# 4  
Old 11-11-2011
Quote:
Originally Posted by boytruc
Thanks. I'm gonna try now.

---------- Post updated at 01:41 PM ---------- Previous update was at 01:02 PM ----------

I miss something, I have to grab image from all folder and sub folder to one folders. I tried your script and it keep the directory.
I get also this for xargs
Code:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

try
Code:
find /home/name/picture -name '*.jpg' -print0|xargs -0 -I '{}' rsync -ab --backup-dir=incremental --suffix=.old '{}' /var/www/media/

or
Code:
find /home/name/picture -name '*.jpg' -printf '"%p"\n'|xargs -I '{}' rsync -ab --backup-dir=incremental --suffix=.old '{}' /var/www/media/

# 5  
Old 11-13-2011
Hello

Thanks for your answer. I just try it. The files are copy but nothing go in 'incremental' folder, so when I edit the name of my copied files and do again the command the files with name's changed are copied again.

It's strange because rsync doesn't do what I want. No suffix and no backup-dir... Smilie
# 6  
Old 11-14-2011
Quote:
Originally Posted by boytruc
Hello

Thanks for your answer. I just try it. The files are copy but nothing go in 'incremental' folder, so when I edit the name of my copied files and do again the command the files with name's changed are copied again.

It's strange because rsync doesn't do what I want. No suffix and no backup-dir... Smilie
* if your files are not modified rsync does not do anything.therefore incremental folder is empty.
* if you change your file's names then rsync behaves on these such as new files and copy t target folder.

regards
ygemici
# 7  
Old 11-21-2011
Quote:
Originally Posted by ygemici
* if your files are not modified rsync does not do anything.therefore incremental folder is empty.
* if you change your file's names then rsync behaves on these such as new files and copy t target folder.

regards
ygemici
Thanks for your feedback.

Anybody have a solution?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Backup solution using rsync

Hello All, I am looking at a fast way to script some backups. I am looking at using rsync to do the leg work. I am having a hard time conceiving a script though. I have a tree with subfolders within subfolders. I was looking at the /xd option to parse the tree. Directory of k:\ ... (4 Replies)
Discussion started by: jvamos
4 Replies

2. Shell Programming and Scripting

Rsync better use for backup

Hello, I have a list of working directory in a remote computer acesssible through ssh and the same directory structure in my home directory of my laptop. I sometimes work on both my laptop and my this other computer. I usually use Rsync this way to synchronize files rsync... (5 Replies)
Discussion started by: ajayram
5 Replies

3. 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

4. Shell Programming and Scripting

rsync backup and recovery options

Hi, Do we have any options in rsync to recover files from the backup? Please share your thoughts. Thanks in advance. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. UNIX Desktop Questions & Answers

Help with excluding .Trashes in an rsync backup

I'm using this script to backup an external hdd to another external hdd - rsync -aE --delete --exclude Volumes/Disk\ A/.Trashes "/Volumes/Disk A" "/Volumes/Disk A Backup"The source drive being "Disk A", and the drive I wish to backup to being "Disk A Backup". I'm constantly getting this error,... (4 Replies)
Discussion started by: Orbient
4 Replies

6. Shell Programming and Scripting

Rsync backup

How do i use Rsync yo pickup only new or modified files from source? I am using rsync -ravzpotu --delete-excluded but sometimes it goes thru all files again (5 Replies)
Discussion started by: sprool
5 Replies

7. Shell Programming and Scripting

rsync script for synchronisation and backup

hello, i need to modified my synch/back scripts.... i want that this script only syncro folders in destinationfolder. f.e. when in destination are two folders 1) admin 2) users but in SOURCE are three: 1) admin 2) users 3) antivirus the script should only increnmential sync the... (0 Replies)
Discussion started by: onkeldave
0 Replies

8. Shell Programming and Scripting

Rotating snapshot backup using rsync

I want to take daily backup(11pm) of /var/www to /mnt/bak excluding /var/www/videos and /var/www/old. HOW to implement a rotating snapshot method, so that i can have multiple(say 4) automatically rotating backups. (0 Replies)
Discussion started by: proactiveaditya
0 Replies

9. Shell Programming and Scripting

lvm/tar/rsync backup script feedback/criticism

I have written a shell script to perform backups using tar, rsync and optionally utilise lvm snapshots. The script is not finished but is in a working state and comments/descriptions are poor. I would greatly appreciate any criticism and suggestions of the script to help improve my own learning... (0 Replies)
Discussion started by: jelloir
0 Replies

10. UNIX for Dummies Questions & Answers

Rsync problems

Hi Im trying to syncronise 4 webserver mirrors, using the rsync command. /www/html is the html documents directory. i am using export RSYNC_RSH="/usr/local/bin/ssh -l $REMOTE_USER" rsyn -va /www/html remotehost:/www/html when this is run, it copies the html file over to the remote... (3 Replies)
Discussion started by: thangorn
3 Replies
Login or Register to Ask a Question