Script to backup data


Forum: Programming and Scripting
Topic: Script to backup data
started by: Mathiou

Posted by Mathiou on July 06 2006,14:46
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

Posted by newOldUser on July 06 2006,15:53
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.
Posted by jpeters on July 07 2006,01:19
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.

Posted by WDef on July 08 2006,09:23
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.

Posted by jpeters on July 31 2006,06:22
Definitely rsync for the big jobs, since it copies only changed files (in addition to lots of options such as --exclude, wildcards, etc.).
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.