LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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-06-2012, 11:32 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Bash: Backup a directory using cp or cpio?


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

Last edited by Xeratul; 12-15-2012 at 10:42 PM.
 
Old 12-07-2012, 12:40 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
why do you want to avoid rsync? This is the "best" and knows perfectly what you need (why do you want to reinvent the wheel?)
 
Old 12-07-2012, 09:02 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If rsync is not allowed to be part of the solution, then the solution will probably be sub-optimal. Ergo, what are the bounds within which a solution is deemed acceptable? Taking the literal meaning of your requirements: 'simple bash tools' would mean using only bash built-in commands, which leaves a quite sparse universe of available tools.
In summary, you need to think about the problem and describe what you are really trying to do. I'm smelling homework here, when the optimal and simple answer cannot be part of the solution.

--- rod.
 
Old 12-07-2012, 09:32 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
because sometimes I use boxes on the network that have not rsync.

If you run a busybox, there is no rsync.

I cannot hack the root to install a rsync.

Besides there is bash and cp/cpio.
 
Old 12-07-2012, 10:53 AM   #5
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
http://www.debianhelp.co.uk/cpiocommand.htm

Literally my first google result from 'cpio backup'
 
Old 12-08-2012, 01:24 AM   #6
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by orgcandman View Post
http://www.debianhelp.co.uk/cpiocommand.htm

Literally my first google result from 'cpio backup'
sure but the aim would be to achieve a backup with deleting the files on the destination that are not anymore on the source.

It is indicated in the above text of this thread.

Quote:
Originally Posted by Xeratul View Post

I would be glad if a solution such as --delete could be proposed in order to mirror the current state of the /harddrive.
 
Old 12-08-2012, 10:30 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Why not just install rsync to a place that doesn't require root privileges? If you're making backups, you must have enough disk quota to accommodate that. Otherwise, just delete all of the backup files, and re-copy the source to the backup destination? Does the backup have to be accessible as part of the filesystem, or can it be a data blob like a tarball, or cpio archive?

--- rod.
 
Old 12-08-2012, 02:34 PM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I think you do not need to "install" rsync, just copy it into your home and you can tell on the other side where can it be found.
 
Old 12-08-2012, 03:37 PM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Not all binaries are transportable in that way. The versions various libraries may not satisfy the linking loader. It should be true that any identical or very similar installations can run copies of the same binary.

--- rod.
 
Old 12-08-2012, 04:42 PM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
/harddrive => /backups/hardrive
Really? The whole hard drive?
 
Old 12-13-2012, 11:25 PM   #11
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Habitual View Post
Really? The whole hard drive?
not really. it was an example.

So there are actually no one interested to develop a bash backup code to sync with --delete option

--
Everyone use X11, KDE, and Rsync where are the geeks ?
 
Old 12-14-2012, 08:01 AM   #12
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Geeks aren't generally interested in developing things that have already been done, unless they can raise the bar somehow. Writing, in bash, an application that already exists is unlikely to fit that description.
--- rod.
 
1 members found this post helpful.
Old 12-14-2012, 09:43 AM   #13
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Why are you using BusyBox? If the goal is to "using simple bash tools (actually linux sys tools such as cp and cpio)"
and BB doesn't have rsync, then I'd RUN to find an alternative to busybox.
Even a broke watch is right twice a day.

Quote:
the aim would be to achieve a backup with deleting the files on the destination that are not anymore on the source.
source what? Busybox seems to be a linux binary program.

No mention of tar...? Curious.
BB includes that.

Statements like "I cannot hack the root to install a rsync." don't help. Hack what root? Who's root?

Who's network resources are you messing with and do you have permission to [cpio|cp|tar|backup]?
Linux cpio Examples: How to Create and Extract cpio Archives (and tar archives)
How do I use cpio command under Linux
https://wiki.archlinux.org/index.php/Tar

Good Luck.
 
Old 12-15-2012, 10:34 PM   #14
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Forget Busybox.

It is amazing that people are so curious, trying to help, and do not stick what is aimed. (please do not take it personally)

The first post is indeed confusing, and can trigger lot of questions. I can definitely understand. This is human.

You find then an example to make it simple, and though they ask thousand questions why not to install rsync or install a debian that has rsync.

I have of course all permissions.

Let's give additional info; this might be easier to understand:

CPIO can be used to backup but it misses the "--delete" option. It creates well the new directories, but to sync it and delete the non-present files in target if there arent anymore in the source dir? For that you need to do it by hand. So why bash? Because you can use it almost everywhere. Some people are traveling, using different machines, ... and portability can sometimes be needed. Some people have not necessarily to seat daily in front of the same computer all their life. So "portability" (script portability) can be an issue for some people.



Quote:
Geeks aren't generally interested in developing things that have already been done, unless they can raise the bar somehow. Writing, in bash, an application that already exists is unlikely to fit that description.
Geeks or hackers do not necessarily use what already exists. If they are making a worm, they code it themselves. If they are sufficiently good enough and skilled, they rather like to use their own program, if they have the time and if needed/preferred. Geeks and hackers are often pioneers in some areas. So mostly they gotta code their own programs in most cases, or to be lucky that a project already exists (GIT,...) and then join it.
Since everyone is different, some rather use what exists other use their own tools.


The aim of this thread is to come to a bash script that can be an alternative to rsync for simple copy/move operations over a mounted sshfs/nfs/samba... It can of course be done on any platforms or machines since cpio is mostly everywhere. Rsync not.


I see that I will not get any reply here on Linuxquestions. I should google on bash forums.

Last edited by Xeratul; 12-15-2012 at 11:02 PM.
 
Old 12-16-2012, 07:19 AM   #15
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
...I see that I will not get any reply here on Linuxquestions. I should google on bash forums.
http://bashscripts.org/forum/viewfor...e93ba9c5638484 may offer some help.
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration