Hudsonvalley
backup
- http://www.cenolan.com/2008/05/simple-linux-to-amazon-s3-backup-script/
- http://www.alvechurchdata.co.uk/softhanoi.htm
- http://s3tools.org/s3cmd
- http://tagmycode.com/snippet/480/backup-mysql-database-to-amazon-s3-with-s3cmd-on-debian#.UMifCoP2GSo
- http://docs.amazonwebservices.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html
- http://en.wikipedia.org/wiki/Backup_rotation_scheme
S3 backup with s3napback
1. Get java working on Ubuntu 10.04 see Ubuntu 10.04 java
2. Install the other needed stuff
sudo cpan Date::Format Config::ApacheFormat Log::Log4perl
3. Download s3napback
cd /usr/local/share lynx http://dev.davidsoergel.com/trac/s3napback/raw-attachment/wiki/Releases/s3napback-1.10.tgz tar xvf s3napback-1.10.tgz
4. create S3 login in /usr/local/share/s3napback/key.txt containing
key=your AWS key secret=your AWS secret (you have to click something on the aws page to see the secret)
5. Set up mysql to not need a password to do a dump.
- In order for mysql to work, the user you're running the script as must be able to mysqldump the requested databases without entering a password. This can be accomplished through by creating a .my.cnf file in the user's home directory putting in it
[mysqldump] user=mysqluser password=secret
Ubuntu 10.04 java
Since $ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" DOESN'T WORK
If you need the real Sun JRE you can:
- goto dir like /usr/local/src or wherever you put stuff you install that's not apt-get
- download java-jre with duinsoft's install script:
- gunzip it
- run the install script
- find out whereis (I found it got installed to /opt/java/32/jre1.7.0_09/bin/java)
- link to it from /usr/local/bin
- restart the shell so your computer can find it
# cd usr/local/src # lynx http://www.duinsoft.nl/pkg/pool/all/update-sun-jre.bin # gunzip update-sun-jre.bin.gz # sh update-sun-jre.bin # cd /usr/local/bin # ln -s /opt/java/32/jre1.7.0_09/bin/java
execute-root-commands-via-php
php include directory
is where to put code that you want to run from multiple different directories. However it can't seem to be set in php.ini. The default is usr/share/php. In order to include files from /usr/local/share/php5/ I put a link in /usr/share/php/ to /usr/local/share/php5/chromephp/ChromePhp.php
console log with ChromePhp.php
now included in /usr/share/php files to see in console whatever you put in ChromePhp::log('hello world'); BTW tutn php consol logging on in top right of browser (blue is on) <syntaxhighlight> <?php include 'ChromePhp.php'; ChromePhp::log('hello world'); </syntaxhighlight>
php error reporting to browser
/etc/php5/apache2/php.ini links to development version that logs errors to browser.
allowing www-data user to write to directory
usermod -a -G group1,group2 username
Where username is the user you want to modify and group1 and group2 are the new groups you want that user to join. Running the command without the -a argument will remove that user from all groups except group1 and group2.
groups sitebuil members cando chgrp -Rv cando /home/pathbost/public_html/ystill
locate
but first updatedb
cron and backups
current crontab in /var/spool/cron/crontab/pathbost
- m h dom mon dow command
- backup MYSQL databases every 4 days (starting at 3:00AM)
00 3 */4 * * cd /home/sitebuil/scripts/S3-Site-Backups; php s3cli_backupDb.php sitebuil_wikidb
05 3 */4 * * cd /home/sitebuil/scripts/S3-Site-Backups; php s3cli_backupDb.php sitebuil_wrdp1
10 3 */4 * * cd /home/sitebuil/scripts/S3-Site-Backups; php s3cli_backupDb.php sitebuil_wuffdb
15 3 */4 * * cd /home/sitebuil/scripts/S3-Site-Backups; php s3cli_backupDb.php taxplans
20 3 */4 * * cd /home/sitebuil/scripts/S3-Site-Backups; php s3cli_backupDb.php webeshoppin
- Delete all local backups older than 3 weeks (at 2am)
00 2 * * * find /var/backups/backup/*.gz -ctime +21 -type f -print | xargs rm -f
crontab to delete files older than 21 days
#Delete all local backups older than 3 weeks (at 2am) 00 2 * * * find /PATH/TO/HOME_DIR/backups/*.gz -ctime +21 -type f -print | xargs rm -f #Run it every three days... 0 0 */3 * *
- backup to S3 code
- cron tutorial another
- Re: Where is crontab stored?
- Root-level crontab should be in /etc/crontab.
- Root-level anacron and periodics should be in /etc/cron*
- User-level crontabs should be in /var/spool/cron/crontabs - they are listed by user, pathbost isactually a chrontab
- select-editor
- even after you change it by yourself you can install it by running
$ sudo crontab -u pathbost /var/spool/cron/crontabs/pathbost
vi with crontab 101
- su to user then 'crontab -e'
- 'i' to insert text
- 'esc :wq to save change, and quit
- then crontab is installed
- 'esc :q!' exits without saving (or installing)
- you can kill your crontab with crontab -r
- you can list the installed crontab with crontab -l
password protecting directories
Directories that are password protected are in /etc/apache2/sites-avalable pathbost and sitebuil
visitor statistics
http://www.hping.org/visitors/doc.html
visitors --output text -A -m 30 /var/log/apache2/access.log -o html >home/sitebuil/public_html/files/webstats.html visitors --output text -A -m 30 /var/log/apache2/other_vhosts_access.log --trails --prefix http://sitebuilt.net -o html > /home/sitebuil/public_html/files/webstatsSBS.html visitors --output text -A -m 30 /var/log/apache2/other_vhosts_access.log --trails --prefix http://pathbost.com -o html > /home/sitebuil/public_html/files/webstatsPATH.html visitors --output text -A -m 30 /var/log/apache2/other_vhosts_access.log --trails --prefix http://levelthefield.us -o html > /home/sitebuil/public_html/files/webstatsLTF.html
other software
that doesn't get put somewhere automatically
- Put source.taz.gz under /usr/local/src
- From /usr/local/bin creagte a link
ln -s ../src/srcdir/compiledbin
securing phpmyadmin
http://paynedigital.com/2011/09/setting-up-and-securing-a-phpmyadmin-install-on-ubuntu-10-04
- 1. setting up ssl certificate
mkdir /etc/apache2/ssl openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.key
- 2. mv phpmyadmin.conf inside a virtual host and put it in sites-available
mv /etc/apache2/conf.d/phpmyadmin.conf /etc/apache2/sites-available/
- 3. edit take out Alias, add virtual host and put in new credentials (pem and key)
- 4. got /etc/apache2/sites-enables and enable it
ln -s ../sites-available/phpmyadmin.conf
- 5. goto /etc/apache2/ports.conf and add
NameVirtualHost 198.23.156.78:443
- 6. restart apache
/usr/sbin/apache2ctl restart
- put a host file entry in windows or from wherever you wan to get to this host
/windows/system32/drivers/etc/hosts 198.23.156.78 nearwater
moving databases
copies as of 12/2012 of databases are on windows machine /documents/sites/mysqldumps
In phpmyadmin of the target mnachine create a user with same nae as source user and put the source ip as host. Create the (empty)databases on the target
root@server1 /var/backups# mysql -u root -p -h localhost pathbost_assess < pathbost_assess.sql root@10.194.101.169: home$ mysqldump -utim -pnji9ol pathbost_h409 | mysql -h198.23.156.78 -utim -pnji9ol pathbost_h409 mysqldump -utim -pnji9ol pathbost_poets | mysql -h198.23.156.78 -utim -pnji9ol pathbost_poets
To copy directories from old vps to new
root@10.194.101.169: home$ rsync -aHvz /home/pathbost/public_html root@198.23.156.78:/home/pathbost
installed lamp stack using https://help.ubuntu.com/community/ApacheMySQLPHP
Run, Stop, Test, And Restart Apache
Use the following command to run Apache :
$ sudo /usr/sbin/apache2ctl start $ sudo /usr/sbin/apache2ctl stop $ sudo /usr/sbin/apache2ctl configtest $ sudo /usr/sbin/apache2ctl restart
Mysql
- Commented out # bind-address = 127.0.0.1 in /etc/mysql/my.cnf so as to access db from any server
$ restart mysql