Linux Format

Answers

Q Speed is not everything

We need to copy a great deal of data from the client’s live server. While doing so, using the cp -R command, the server slows down quite a bit. Copying after 5pm, out of office hours, helps but we also need to copy during the day, at a lower speed, so people can use the server without annoying delays. How do we slow down the file copy command?

Corey Richardson

The short answer is that you do not use cp to copy the files. By using Rsync, you can limit the bandwidth used in file transfers, thanks to its --bwlimit option. The option takes a number that is interpreted as KiB per second, although you can also use a suffix to give a different unit, for example --bwlimit=2.5m.

Rsync has a number of other advantages over plain cp . Firstly, it can operate over an SSH connection, as it does by default when connecting to a remote host, which means all data travels through a secure tunnel. This may be important when transferring company data. Also, Rsync is well suited to recovering from interrupted transfers; run it again and it picks up where it left off. To make a copy of a directory on the remote server, you would use something like: $ rsync --bwlimit=5m user@server:/path/to/dir//path/to/local/copy/

Ensure that both paths include the trailing slash. This makes the local directory a copy of the remote one, copying only those files that are new or changed, another saving in bandwidth.

As you make the distinction between copying during and after office hours, you may alsoto abort the transfer at the given time, so you could run at higher speed at night, then resume at a lower rate when people in the office need the bandwidth. Running the following would transfer at a higher speed until 8am, then stop that transfer and resume it at a lower speed: $ rsync --bwlimit=10m --stop-at=08:00 user@server:/path/to/dir//path/to/local/copy/

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format4 min read
Linux
The #1 open source mag Future Publishing Limited, Quay House, The Ambury, Bath, BA1 1UA Email contact@linuxformat.com EDITORIAL Editor-in-chief Neil Mohr Art editor Fraser McDermott Production editor Katharine Davies Group editor-in-chief Graham Bar
Linux Format3 min read
Kernel Watch
Linus Torvalds announced the fourth RC (Release Candidate) for what will become Linux 6.9 in another few weeks. In his announcement, he noted that there was “Nothing particularly unusual going on this week – some new hardware mitigations may stand o
Linux Format1 min read
Sql At Fifty
Structured Query Language (SQL) is 50 years old. It is the only programming language from the ’70s that is still around and – unlike COBOL and Fortran, which are confined to limited niche roles – still thriving and expanding. In 2023, the IEEE declar

Related Books & Audiobooks