Results 1 to 3 of 3
Hi
I’m still new to Linux so you have to forgive me, I am trying to compress a folder and the contents within, while keeping the permissions the same. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-14-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 21
Need my script to check if compress folder is corrupt or not
Hi
I’m still new to Linux so you have to forgive me, I am trying to compress a folder and the contents within, while keeping the permissions the same. I then need to check if the compress file is corrupt or not. Base on that result I need to transfer the file (I can do that myself)
Any help would be appreciated
cd /home/ops/Desktop/temp
tar cvzfp backup-"$(date +%d-%b-%y)".tar.gz /home/ops/Desktop/dir1
gunzip -tl backup-"$(date +%d-%b-%y)".tar.gz
- 02-14-2011 #2Linux Newbie
- Join Date
- Apr 2010
- Location
- Novosibirsk, Russia
- Posts
- 136
I don't think you need to check TAR's work
If there any errors appeared while compressing file, you will see them immediatly at your terminal.
In general, you can always check the integrity of your original file by calculating its checksum. It looks like you calculate it using `md5sum`command (before compressing), then anyone who uses your file can check it after decompression, using this checksum. Compression looks like some king of encryption where you change binary representation of data. It means that you can't get access to original file in archive without decompression.
- 02-14-2011 #3Just Joined!
- Join Date
- Jan 2011
- Posts
- 21
Ok thanks for the advice I manage to find this command of this forum to compare two files
see below
diff <(md5sum /home/ops/Desktop/test1/test.txt| awk '{print $1}') <(md5sum /home/ops/Desktop/test3/test.txt | awk '{print $1}')
if the files match there is no output which if find
I then change a file on purpose to see what i get which is this
1c1
< b9628c4ab9b595f72f280b90c4fd093d
---
> d41d8cd98f00b204e9800998ecf8427e
.
How in a bash script would I write something if both files match I get E-mail alert saying the backup was successful and if not E-mail would alert the backup failed. Sorry to ask It's just being new to Linux I just not sure of how the syntax would go.


Reply With Quote
