Programming and Scripting :: Script to backup data
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 regardsDon'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.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.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.Definitely rsync for the big jobs, since it copies only changed files (in addition to lots of options such as --exclude, wildcards, etc.).Next Page...
original here.