:::: MENU ::::
Posts tagged with: administration

Repetitive rsync

Some time ago I’ve been moving from one hosting provider to another. I had to transfer the files from A to B and used rsync for that. But unfortunately rsync command was crashing due to some timeouts. So I’ve found really nice script for auto restore.

rsync-auto.sh

#!/bin/bash

while [ 1 ]
do
    /usr/bin/rsync -avz --progress $1 $2
    if [ "$?" = "0" ] ; then
        echo "rsync completed normally"
        exit
    else
        echo "Rsync failure. Backing off and retrying..."
        sleep 10
    fi
done

Execute

rsync-auto.sh SOURCE DESTINATION

source: stackoverflow.com




Useful curl

Headers only

--head – performs HEAD http request (not GET).

curl --head https://www.wp.pl/

Content + headers

--get – performs GET request
-i – include headers

curl --get -i https://www.wp.pl/

Low bandwidth copy

So, you have to copy one directory into another on your server and you don’t want to kill the machine?

Instead of

cp -r master master_copy

use

rsync --bwlimit=30000 -av master/ master_copy/

The –bwlimit=KBPS switch is for limiting I/O bandwidth.



Full MySQL dump

If you would like to dump all tables and triggers and stuff try this one:

mysqldump -uUSER -p -R --opt --triggers DB > DB_DUMP.sql

but if you have some troubles with permissions for locking tables use --lock-tables=false

mysqldump -uUSER -p -R --opt --triggers --lock-tables=false DB > DB_DUMP.sql