You are not logged in.

#1 2017-12-17 12:37:47

Asbestbrezel
Member
Registered: 2014-07-27
Posts: 67

[solved] Fastest way to copy files and directorys with a backup-script

Hello,

i wrote a little backup-script using cp to copy all the files and directories. It works, but its extremely slow.
Is there a faster way to do this?

Greetings,
marcel

Last edited by Asbestbrezel (2017-12-17 13:32:00)

Offline

#2 2017-12-17 12:46:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [solved] Fastest way to copy files and directorys with a backup-script

How could we know.  You haven't shown us the script.  Rsync is generally preferred to cp for this purpose - but not due to speed concerns.

What part is slow?  If it's I/O bound then the only way to speed it up would be to get faster disks or connections to the disks (or maybe compress the data before transfer, but this all depends on many things you've not shared here).

Last edited by Trilby (2017-12-17 12:48:10)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2017-12-17 12:57:39

Asbestbrezel
Member
Registered: 2014-07-27
Posts: 67

Re: [solved] Fastest way to copy files and directorys with a backup-script

#!/bin/bash
mkdir BACKUP_$(date +%d_%m_%Y)
cd BACKUP_$(date +%d_%m_%Y)
mkdir foo

cp /foo1 ./foo
cp /foo2 ./
cp /foo3 ./
cp /foo4 ./
cp -r /foo5 ./
cp -r /foo6 ./

Its very simple, not even a script. Normally it should be executed on the same SSD, the files are on. So read and write has the same disk as destination.
So basically the question is, is there a faster way to copy, then cp?

Last edited by Asbestbrezel (2017-12-17 12:59:36)

Offline

#4 2017-12-17 13:24:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [solved] Fastest way to copy files and directorys with a backup-script

I have no idea why you'd feel the need to obfuscate the content of that script.  That really disinclines me from even bothering to continue - which I wont after this post.  But to answer your direct question, no there is not a faster way to cp than cp.  And to even answer the question you're not asking but probably should be asking, yes there is a much faster way to acheive what it looks like you are trying to do: incrememental backups with rsync.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2017-12-17 13:29:46

Ben00it
Member
Registered: 2017-09-21
Posts: 9

Re: [solved] Fastest way to copy files and directorys with a backup-script

Yes try incremential (--delete) backup with rsync, in any case you'll win processing time by not recopying the source files unchanged.

Offline

#6 2017-12-17 13:31:27

Asbestbrezel
Member
Registered: 2014-07-27
Posts: 67

Re: [solved] Fastest way to copy files and directorys with a backup-script

Thank you, sir. This answers my question.

Offline

Board footer

Powered by FluxBB