Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-17-2012, 05:58 AM   #16
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,792

Rep: Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888

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, 08:55 AM   #17
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852Reputation: 4852

Originally Posted by Xeratul View Post

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:
- 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)

- 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 09:45 AM. Reason: fixed stupid typo
Old 12-17-2012, 09:18 AM   #18
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.


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-22-2012 12:37 AM
Full Backup With Cpio! grim2 Linux - General 6 02-09-2012 07:43 AM
[SOLVED] excluding directory from backup in bash... astanton Programming 6 06-30-2011 07:56 PM
CPIO backup / configuration exactiv Linux - Software 3 05-25-2009 10:51 AM
Using cpio to backup to CDROM Cyberhund Linux - Newbie 3 07-21-2004 02:49 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:28 AM.

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