Backup script to split and tar files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Backup script to split and tar files
# 1  
Old 06-17-2012
Backup script to split and tar files

Hi Guys,

I'm very new to bash scripting. Please help me on this.

I'm in need of a backup script which does the ff.

1. If a file is larger than 5GB. split it and tar the file.
2. Weekly backup file to amazon s3 using s3rsync
3. If a file is unchanged it doesn't need to copy to amazon s3

I've searched google and can't find a script that suit my needs.

Can anyone post some of their scripts or links for reference which may help?

Thank you.
# 2  
Old 06-18-2012
To find any file that is larger than 5Gb AND has been modified in the last week you can use:

Code:
find / mtime -7 -size +10485760 -print

Note: size is in 512 byte blocks hence 10485760 x 512 = 5,368,709,120 (5Gb).
mtime -7 is modification time less than 7 days ago
# 3  
Old 06-18-2012
Thank you Chubler_XL for the input.

But I already created a directory where in all of the users copy their files for backup. My task now is to compress it and split it less than 5GB automatically. In preparation for backup to amazon s3.

I think it is possible in bash scripting, but since I'm a newbie here. I find it difficult to do the task. Can anyone give me sample of their bash script related on this topic? or any sites that can help me to solved this problem?

Thank you very much.
# 4  
Old 06-18-2012
Try this:

Code:
cd /path/to/your/back/files
tar cz --remove-files -f ./backup.tgz ./*
split -b 4g backup.tgz backup.

This will compress all the files in the path into 1 big backup.tgz (tar gzip) file and then split the file into a heap of 4Gb pieces. Each piece will be named like backup.aa, backup.ab, backup.ac, etc.

Assumption is that everything under the path is to be backuped up and removed once done.

Now transfer the files as you normally would and remove the backup.* files when the transfer is completed OK.


To re-extract the files try cat backup.* | tar xzf -

Last edited by Chubler_XL; 06-18-2012 at 01:27 AM..
# 5  
Old 06-18-2012
to make it more specific, I created a directory called /backups it has a subdirectories named after each user. (user1, user2, user3). Now, each users will copy all their files that they need to backup on their respected folders. How can I automatically split and tar the files even if without knowing the name of the file?

I'm getting the point of your input. but I'm in need of a script which can automatically do the split and tar things. I know cron will do the automated job. My biggest problem is the script itself.

Sorry for being noob here and I hope you'll understand my situation.

Thank you,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append files (backup .tar)

Hi all, I have to write a script which will keep for a particular user (username is first argument) backups of the account area to another. The script should accept as the second argument is a directory (or file), create one by storing a copy of the argument (using tar) and copies it to the list... (0 Replies)
Discussion started by: peter20
0 Replies

2. UNIX for Dummies Questions & Answers

Remote FTP Backup -Tar archive+ encrypt+ split to a remote ftp

I have a huge directoy(200+ gb) for backup. I want upload the tar file(split files) simultaneous to a remote ftp. (pipeline, stdout, stdin etc.) I don't want write a data to local hdd. I have a ssd hdd. thanks. this code doesn't work.( yes i know the problem is split command!) tar cvzf -... (8 Replies)
Discussion started by: tara123
8 Replies

3. Shell Programming and Scripting

Backup files in tar format

Hi, I need backup all the files(including sub directories files ) which we modified today and create the tar file with the filename_<current_date>.tar Thanks (1 Reply)
Discussion started by: gavemani
1 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. Shell Programming and Scripting

Not correct processing of “\ “ in names of dirs inside shell script (tar command - system backup scr

Hello, Recently, I've started with shell scripting, and decided to write a script for my system backup using tar. When I was dealing with tar execution inside shell script I found this, inside shell we have the following code: tar $TAR_PARAMS $ARCHIVE_FILE $EXCLUDE $BACKUP_STARTwith... (6 Replies)
Discussion started by: ilnar
6 Replies

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

7. UNIX for Advanced & Expert Users

Do incremental backup without tar files up

I'm trying to do a incremental backup for a big NFS. Since space is not an issue, I don't want to compress them or end up with a big tarball for full backup( and a series of small tarballs for incremental backup). Basically I want the TAR backup/restore functionality but not TAR files up.... (3 Replies)
Discussion started by: overmindxp
3 Replies

8. Shell Programming and Scripting

Problem with tar in a backup script

I had an idea of very-very easy bacup script that packs ALL of the files in current dir (including the subfulders and with spaces in name), packs them with tar+gz and moves to a directory. I'm using Cywin under WinXP. But I have a problem with tar. When I do in a single line "tar -rf... (2 Replies)
Discussion started by: TennageWerewolf
2 Replies

9. Shell Programming and Scripting

Diff. Backup Script Using TAR. Should be simple.

I'm specifically trying to find help or insight on using the --incremental ('-G') option for creating a tar. Please resist the urge to tell me to use --listed-incremental ('-g') option. That's fairly well documented in the GNU tar manual. GNU tar 1.19 This is what the manual does say in section... (0 Replies)
Discussion started by: protienplant
0 Replies

10. Shell Programming and Scripting

How to process the files using .tar.gz files in script

Hi, I have some file in /users/xyz directoty with .tar.gz extension. i need to find these files and if found in need to run other commands. I now the command for finding files,but how to put if condition ?please help me Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies
Login or Register to Ask a Question