LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-17-2012, 04:58 AM   #16
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,466

Rep: Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213

I think there is no any "pioneer" work in your case. There is a problem and you have a special environment. You can of course look on another forum for tips, but I do not think you will find much better tips. Anyway, if you have a solution you can inform us too.

Rsync can be hardly implemented in bash, it has a lot of features. As far as I see you need to develop some script to achieve your goal. Why didn't you try the tip I gave you:
first step copy rsync bynary with ssh to the target host, second step: use rsync over ssh. Just remember, any other solution will be much longer and much more difficult.
 
Old 12-17-2012, 07:55 AM   #17
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,364
Blog Entries: 2

Rep: Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981
Post

Quote:
Originally Posted by Xeratul View Post
Hi,

The goal is simple, making a backup using simple bash tools (actually linux sys tools such as cp and cpio) for:

/harddrive => /backups/hardrive


I would be glad if a solution such as --delete could be proposed in order to mirror the current state of the /harddrive.

The aim is to avoid rsync use.

Would you have any simple solution that might be proposed?

thank you in advance

The first thing that you always should do when trying to write a script or program is to break down your problem into smaller sub-problems.

For example, your backup problem can at first be divided into two sub-problems:
- the actual backup
- the removal of files that no longer exist on the source

You can break down these sub-problem into smaller problems:
Backup:
- find files which have to be backed up (pretty easy if the backup is scheduled on a timely basis, for example every 24 hours, just find all files with a newer creation/modification time, find can do that)
- copy them with preserving the path (the --parents option of cp can do that, can also be done using tar or cpio)

Removal:
- find all files that are potential candidates for removal in the backup folder (files that are younger than the last backup have just been copied by you, so you need only to check files that are older)
- check if those files exist under the same relative path in the source directory (a case for Bash parameter substitution and the test command), if not delete the file in the backup

With breaking the problem down this way it shouldn't be that hard to come up with a Bash script for the wanted functions.

Last edited by TobiSGD; 12-17-2012 at 08:45 AM. Reason: fixed stupid typo
 
Old 12-17-2012, 08:18 AM   #18
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by Xeratul View Post
The aim of this thread is to come to a bash script that can be an alternative to rsync
But I thought you are using busybox and bash is not built into busybox. So if you can install bash, why can you not install rsync?
--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using CPIO for backup Noewon Linux - Newbie 2 08-21-2012 11:37 PM
Full Backup With Cpio! grim2 Linux - General 6 02-09-2012 06:43 AM
[SOLVED] excluding directory from backup in bash... astanton Programming 6 06-30-2011 06:56 PM
CPIO backup / configuration exactiv Linux - Software 3 05-25-2009 09:51 AM
Using cpio to backup to CDROM Cyberhund Linux - Newbie 3 07-21-2004 01:49 PM


All times are GMT -5. The time now is 12:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration