online marketing

Archive for category server

Automatic Backup With Rsync And Cron On Ubuntu

Keeping a directory automatically backed up somewhere is always useful. Every few months this is needed on one machine or another. Here are the steps:

  1. First set up ssh keys so passwords are no longer needed.
    1. Test things by verifying a ’ssh user@yourserver.com’ does require a password.
    2. Make some ssh keys on your client and then move the public key to the server
      1. cd ~/.ssh
      2. ls
      3. ssh-keygen -t dsa (Keep the defaults by just pressing enter a few times.)
      4. scp id_dsa.pub user@yoursever.com:.ssh/
    3. Now set things right on the server
      1. ssh user@yourserver.com
      2. cd ~/.ssh
      3. cat id_dsa.pub >> authorized_keys
      4. rm id_dsa.pub
      5. exit
    4. Test things by verifying a ’ssh user@yourserver.com’ no longer requires a password.
  2. Determine the directory to be backed up and where it will be backed up and test the command to be used.
    1. time rsync -atvz ~/local-directory-of-your-choosing/ user@youserver.com:remote-directory-of-your-choosing/
    2. log in the server and verify the files are there…
  3. Put the command in cron. Because cron is broken in ubuntu you can’t simply do “crontab -e” anylonger. (How can something so basic be broken?!) Instead follow these instructions:
    1. vi ~/some_file and put in the cron commands
    2. @hourly rsync -atvz ~/local-directory-of-your-choosing/ user@youserver.com:remote-directory-of-your-choosing/
    3. crontab ~/some_file
    4. crontab -l

Now simply test it out…

Sumber :

http://ioconnor.wordpress.com/2009/07/25/automatic-backup-with-rsync-and-cron-on-ubuntu/

  • Share/Bookmark

No Comments

Membuat startup scripts on ubuntu

untuk membuat skrip yang akan di load otomatos saat start up pada ubuntu:

  1. buatlah script yang anda butuhkan, dan pastikan script tersebut di awali dengan “#!/bin/bash“.
  2. Buat script tersebut executable, dengan perintah “sudo chmod +x <nama file>
  3. kopikan script tersebut ke “/etc/init.d./
  4. langkah terakhir jalankan update-rc.d dengan command, “sudo update-rc.d <nama filr> defaults“.

untuk membuang file agar tidak di jalankan saat booting:

  1. delet file tersebut, “sudo rm /etc/init.d/nama_file
  2. kemudian jalan kan perintah “sudo update-rc.d <fnama_file> remove

Lihat videonya disini.

salam

Ardlian

  • Share/Bookmark

No Comments