Default image

mysql easy backup and restore

In essence in order to fully backup and restore a MySql database server, you just need to use two commands mysqldump and mysql. For a “small databases” scenario you can find at the end a simple script to send the backup by e-mail. In conjunction with crontab you can almost name it a backup policy. MySQL backup> mysqldump -u <user> -p <passwd> --all-databases > <backup file> MySQL restore> mysql -u <user> -p <passwd> < <backup file> mysql --execute "update mysql.user set host='old' where host='host';" Backup script example #!/bin/bash # This script runs nightly to back a MySQL database to a e-mail account DATE1=`date +%D` DATE2=`date +%Y%m%d%H%M` # The email address that receives backups ADDRESS="alias@domain" # Local temp directory BACKUPDIR="/tmp" # MySQL username and password MYSQLUSER="user" MYSQLPASS="pass" # MySQL database to backup (or --all-databases to backup everything) DATABASE="--all-databases" # Name of backup file FILENAME="mysql\_backup" # Change to the backup directory cd $BACKUPDIR # Dump the MySQL databases to a plaintext file mysqldump -u $MYSQLUSER -p $MYSQLPASS $DATABASE > $FILENAME\_$DATE2 # Package (tar) and compress (gzip) the plaintext MySQL dump tar czf $FILENAME\_$DATE2.tar.gz $FILENAME\_$DATE2 # Mail the resulting archive to our Gmail account date | mutt -s "$FILENAME ($DATE1)" -a $FILENAME\_$DATE2.tar.gz $ADDRESS thanks to Bruno Rodrigues

September 10, 2006 · 1 min · 204 words · João Malcata
Default image

add / remove registry entries

In order to import registry changes use this command on the following .reg file examples. regedit /S <reg file> Add/update key and value Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\ExampleKey] "StringValue"="example" Remove key (including all values) Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\ExampleKeyToRemove] Remove value Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\ExampleKey] "ExampleStringValue"=-

September 10, 2006 · 1 min · 50 words · João Malcata
Default image

Toolbar on XP taskbar hack

Due to some sort of domain policies you might be unable to have toolbars on the XP taskbar. Create a batch file and add it to the startup scritps with the following text: regedit /S "<path>\hacktoolbar.reg" Create a .reg file hacktoolbar.reg: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoToolbarCustomize"=dword:00000000 "NoBandCustomize"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoToolbarsOnTaskbar"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoSaveSettings"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoActiveDesktop"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "ClassicShell"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoCloseDragDropBands"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoMovingBands"=dword:00000000

September 10, 2006 · 1 min · 61 words · João Malcata
Default image

cygwin a windows saviour

If you “have” to use Windows, are able to install software but lack disk access cygwin is the answer to your prayers. Use the setup file everytime you want to install or add packages. Nice cygwin configuration Admin - cygrunsrv shutdown Archive - unzip Base - alternatives ash base-files base-passwd bash coreutils cygwin cygwin-doc diffutils editrights findutils gawk gdbm grep gzip libgdbm libgdbm-devel libgdbm3 libgdbm4 libncurses5 libncurses6 libncurses7 libncurses8 libreadline4 libreadline5 libreadline6 login man ncurses run sed tar termcap terminfo which zlib Database - libdb4.1 libdb4.2 libdb4.3 Devel - expat gettext ioperm libiconv mktemp pcre ruby Doc - cygwin-doc expat man texinfo Editors - joe Interpreters - expat gawk perl ruby Libs - crypt expat fontconfig freetype2 gettext ioperm libXft libXft1 libXft2 libbz2\_1 libcharset1 libfontconfig1 libfreetype26 libiconv2 libintl libintl1 libintl2 libintl3 libncurses5 libncurses6 libncurses7 libncurses8 libpcre0 libpopt0 libreadline6 ncurses openssl openssl097 tcltk termcap zlib Net - ncftp netcat openssh openssl openssl097 rsync Perl - perl Shells - ash bash chere rxvt System - chere ioperm man ping util-linux Text - expat groff less texinfo util-linux Utils - bzip2 chere cygutils e2fsprogs pcre util-linux Web - wget X11 - X-startup-scripts xorg-x11-base xorg-x11-bin xorg-x11-bin-dlls xorg-x11-bin-lndir xorg-x11-etc xorg-x11-f100 xorg-x11-fenc xorg-x11-fnts xorg-x11-libs-data xorg-x11-nest xorg-x11-xwin xterm **cygwin friendly shell** C:\cygwin\bin\rxvt.exe -fn "Lucida Console-11" -bg black -fg white -ls -st -sr -sl 1000 -C -e /usr/bin/bash --login

September 8, 2006 · 2 min · 221 words · João Malcata
Default image

Subversion cookbook installation

This is a cookbook for a SubVersion (aka svn) installation on debian and apache2 with LDAP integration authentication. Install subversion apt-get install subversion Configure subversion mkdir /var/lib/svn svnadmin create /var/lib/svn/repos chown www-data:www-data /var/lib/svn/repos/ -R Install Apache2 apt-get install apache2 Set apache2 modules apt-get install libapache-mod-ldap libapache-auth-ldap libapache2-svn If needed enable modules a2enmod ldap a2enmod auth_ldap Setup Apache2 website Create folder mkdir /var/www/svnwebsite Create website configuration file usually in /etc/apache2/sites-available ...

August 25, 2006 · 1 min · 183 words · João Malcata
Default image

Multiple web sites installation on wordpress

Here are the basic steps to install another wordpress weblog on a multiple web sites infrastructure over a single apache2 on debian. 1. Create the new database In order to pick a consistent database name, check the existing databases and create a new one. Then create a new username and give it full access. mysql> SHOW DATABASES; mysql> CREATE DATABASE <databasename>; mysql> SELECT User, Password, Host from user; mysql> GRANT ALL PRIVILEGES ON <databasename>.* TO <username>@<hostname> INDENTIFIED BY <password>; mysql> FLUSH PRIVILEGES; mysql> EXIT; 2. Setup the wp-config file 2.1 Copy wp-config.php to config-<website>.php 2.2 Update config-website.php constants with the info from above define('DB\_NAME', '<databasename>'); // The name of the database define('DB\_USER', '<username>'); // Your MySQL username define('DB\_PASSWORD', '<password>'); // ...and password define('DB\_HOST', '<hostname>'); // 99% chance you won't need to change this value 3. Setup Apache2 web site 3.1 Create a website path ln -s /usr/share/wordpress /var/www/<website> 3.2 Create logs folder mkdir /var/log/apache2/<website> 3.3 Create a new apache configuration file for the website /etc/apache2/sites-available/<website> <VirtualHost *:80> ServerName <website> ServerAdmin webmaster@<domain> DocumentRoot /var/www/<website>/ <Directory /var/www/<website>> Options ... # hack for nice URIs <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> </Directory> ... LogLevel warn ErrorLog /var/log/apache2/<website>/error.log CustomLog /var/log/apache2/<website>/access.log combined ... </VirtualHost> 3.4 Enable the new website a2ensite website 3.5 Reload Apache2 configuration /etc/init.d/apache2 reload 3.6 Run the install script: https://<website>/wp-admin/install.php And Voila, you have a new weblog. ...

August 23, 2006 · 2 min · 242 words · João Malcata