Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Script to backup data< Next Oldest | Next Newest >
Mathiou Offline





Group: Members
Posts: 1
Joined: July 2006
Posted: July 06 2006,14:46 QUOTE

Hello,

I want to backup my data, so I would like to have a little script in order to copy all files, folders and sub-folders that are on my HDD (hda2) to an external HHD.
To speed up the process, the script could compare files and if they are the same (let say same date and same size), ignore it.

Anyone could write something for me ???

PS: I don't want to obtain an image of the HDD or a compressed archive, just a copy of files and structure.

Thanking you in advance,
Best regards
Back to top
Profile PM 
newOldUser Offline





Group: Members
Posts: 241
Joined: Oct. 2004
Posted: July 06 2006,15:53 QUOTE

Don't have time for a long answer but you can search for something called rsync.  I think it will do what you want.  I may have written something in the blog pages about it also.  Try a forum search first.

--------------
======== Note =========
The DSL Forum Search default is 'OR'
If you search for "cat dog" you will get all "cat" posts and all "dog" posts.
If you search for "cat AND dog" you will only find results that contain BOTH "cat" and "dog"
Add '*' for wildcards, " cat* and dog* "
Back to top
Profile PM 
jpeters Offline





Group: Members
Posts: 804
Joined: April 2006
Posted: July 07 2006,01:19 QUOTE

write  in an editor:  

#!/bin/bash
cp path/* path/backupFolder

Save file as something like "backup" and then run "bash backup"

The * serves as a wildcard, backing up all files in the folder to the backup folder.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: July 08 2006,09:23 QUOTE

cp is not the best tool for backing up partitions. Use tar or rsync.  Here's tar.

Suppose your data is on /mnt/hda2 and you want to copy all this across to /mnt/hda9, preserving perms where possible and dir structures etc.

Make sure /dev/hda2 and /dev/hda9 are both mounted and try this:

Code Sample
cd /mnt/hda2; tar -cvf - . | ( cd /mnt/hda9; tar -xvf - )


Put this in a script or run it from a shell.

But remember that fat/vfat partitions don't have any concept of permissions.
Back to top
Profile PM 
jpeters Offline





Group: Members
Posts: 804
Joined: April 2006
Posted: July 31 2006,06:22 QUOTE

Definitely rsync for the big jobs, since it copies only changed files (in addition to lots of options such as --exclude, wildcards, etc.).
Back to top
Profile PM 
4 replies since July 06 2006,14:46 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Script to backup data

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code