Archive for the ‘ Q&A ’ Category

Backup linux server

Posted in Examples, Q&A on September 13th, 2010 by cmanolescu – 1 Comment

A simple way to backup your server.

Backup mysql database:

mysqldump -u $mysqlUser -p$mysqlPassword database > dump.sql

or you can dump all databases to a single sql file

mysqldump -u $mysqlUser -p$mysqlPassword --all-databases > dump.sql

Backup postgresql database:

pg_dumpall -U user > dump.sql

but because this will execute on server there will be no user interaction so for this to work you need to create a .pgpass file in your home directory.
NOTE: make sure it has permission 600 or else it will be ignored.

cat > ~/.pgpass << ^D
host:port:*:user:password
^D
chmod 600 ~/.pgpass

You may need a remote server where to store your backup and you also want to connect without providing a password (a good tutorial can be found here).
NOTE:
a) make sure ~/.ssh exists on remote server and it has permissions 700
b) use “-p port” if ssh is not on the default port

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub "-p port remoteUser@remoteHost"

An easy way to backup your files on a remote server is to use rsync

rsync -e "ssh -p remotePort" -avrp localPath remoteUser@remoteHost:remotePath

Create cron job

cat > /etc/cron.weekly/remote_backup << ^D
#!/bin/sh
######### Start backup script #########

######### End backup script ##########
^D
chmod 700 /etc/cron.weekly/remote_backup

Backup a folder to a tar archive

tar zcvf /archive/etc.tgz /etc/

or backup the entire server

tar -zcvpf /archive/full-backup-`date '+%d-%B-%Y'`.tar.gz \
    --directory / --exclude=archive --exclude=mnt --exclude=proc --exclude=var/spool/squid

Download complete backup script

Flex unit testing without a Serial Number for Flash Builder 4 PREMIUM

Posted in Flex, Q&A on August 17th, 2010 by bogdan – 1 Comment Tags: , , , , ,

Flash Builder 4 comes in 2 flavors: Standard Edition and Premium. With Standard Edition you can’t run unit tests inside Eclipse. If you’re reading this post then I guess you’re looking for an easy and free way of unit testing your flex application. There is a easy way of doing this. All you have to do is create a project, add some swc libraries and set up unit testing.

For a Flex 4.1 environment, you’ll need to add flexunit-core-flex-4.1.0 and flexunit-uilistener-4.1.0 libraries to your project, write test classes and suite class to include the tests, and in the end you should write a little code to Default Application file.

Here is a sample unit testing project you can look over.

The whole post was meant to be short and provide a simple, but reliable way of unit testing in Flex.
For more details and more advanced features you can check out the official website.