Thursday, July 18, 2013

Backup LPSE menggunakan synology via rsync

backup  server LPSE  linux  ke synology via rsync adalah sebagai berikut :
1. Buat Key untuk ssh, menggunakan perintah ssh-keygen pada server linux

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
6f:9f:b3:18:31:2e:b6:96:47:0f:4c:8d:6c:da:8e:da root@lpse
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|         . o     |
|          = .    |
|        S*o      |
|        .o=o     |
|        o==o     |
|       o++o+o.   |
|      .oE.. +o   |
+-----------------+

2. copy ssh key pada synology menggunakan perintah ssh-copy-id -i /root/.ssh/id_rsa.pub [user]@[ipsynology]
 
ssh-copy-id -i /root/.ssh/id_rsa.pub backuplpse@172.17.1.98
backuplpse@172.17.1.98's password:
Now try logging into the machine, with "ssh 'backuplpse@172.17.1.98'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

3. Coba login pada synology tanpa memasukkan password


ssh backuplpse@172.17.1.98

BusyBox v1.16.1 (2013-04-16 20:13:10 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

DiskStation>

Klo sudah bisa login tanpa password berarti sudah ok

4. ketik exit untuk kembali ke server linux

5. Buat folder /home/backup
6. Dump database  su postgres -c 'pg_dump -Fc -f /home/backup/epns_prod`date +%H-%M-%d-%m-%y`.backup  epns_prod'

 7. Rsync ke synology

rsync -az /home/backup/  backuplpse@172.17.1.98:/volume1/homes/backuplpse/dumpdb

8. Masuk ke synology , anda akan dapat melihat backup database pada direktory  /homes/backuplpse/dumpdb

9. Masukkan script pada crontab











No comments:

Post a Comment