Comprendre Python en vidéo

Pré-requis:

  • Etre disponible au moins 2 heures
  • Lire et comprendre l’anglais

Google Tech Talks February 21, 2007

ABSTRACT
The Python language, while object-oriented, is fundamentally different from both C++ and Java. The dynamic and introspective nature of Python allow for language mechanics unlike that of static languages. This talk aims to enlighten programmers new to Python about these fundamentals, the language mechanics that flow from them and how to effectively put those to use. Among the topics covered are duck-typing, interfaces, descriptors, decorators, metaclasses, reference-counting and the cyclic-garbage collector, the divide between C/C++ data and Python objects and the CPython implementation in general. This talk is part of the Advanced Topics in Programming Languages series. The goal of this series is to encourage all of the people at Google who know and love programming languages to share their knowledge. If you would like information on upcoming talks, or to schedule a talk of your own, contact information is available on the wiki page.

App

Sauvegarder un blog wordpress sur une clef usb

Objectif

Sauvegarder/Restaurer un blog de type WordPress:

  • sauvegarde des fichiers PHP
  • export SQL de la base de données

Langage de script utilisé: Bash

Script de Sauvegarde

wp-backupblog.sh

#!/bin/bash
# wp-backupblog.sh - Backup WordPress Blog
# version: 0.1
# Author: Benjamin Baudouin
# http://www.benjaminbaudouin.com
DEVICE=/dev/sda1
SRCDIR=/var/www/wordpress
USBKEYDIR=/media/usbkey/
TMPDIR=/tmp/backupblog/
ARCHIVE=blog.$(date +%Y%m%d).tar.gz
ARCHIVE_SQL=blog.$(date +%Y%m%d).sql
MYSQL_USER=root
MYSQL_PASS=*****************
MYSQL_DB=wordpress
#creation du repertoire tmp
if [ ! -e ${TMPDIR} ]
then
mkdir ${TMPDIR}
fi
#evaluation de la taille du blog
echo -e "Taille du blog (non compresse):"
du -sh ${SRCDIR}
#creation de l'archive (fichiers sources)
echo -e "Creation de l'archive ${ARCHIVE} ..."
cd ${SRCDIR}
tar cf - ${SRCDIR} | gzip > ${TMPDIR}${ARCHIVE}
echo -e "Taille du blog (archive compresse .tar.gz):"
du -sh ${TMPDIR}${ARCHIVE}
#creation de l'archive (fichier SQL)
echo -e "Creation de l'archive ${ARCHIVE_SQL} ..."
mysqldump -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} > ${TMPDIR}${ARCHIVE_SQL}
echo -e "Taille du blog (archive .sql):"
du -sh ${TMPDIR}${ARCHIVE_SQL}
echo -e "Taille total blog"
du -sh ${TMPDIR}
#si pas d'automount, montage manuel
mount ${DEVICE} ${USBKEYDIR}
#copy
cp -rf ${TMPDIR} ${USBKEYDIR}
echo -e "\nCopie sur la clef usb ..."
#demontage
umount ${DEVICE}
if [ $? -eq 0 ]
then
echo -e "\nDone"
fi
exit 0

Script de Restauration

wp-restoreblog.sh

#!/bin/bash
# wp-restoreblog.sh - Restore WordPress Blog
# version: 0.1
# Author: Benjamin Baudouin
# http://www.benjaminbaudouin.com
DEVICE=/dev/sdb1
USBKEYDIR=/media/usbkey
BACKUPDIR=/media/usbkey/backupblog/
SRCDIR=/var/www/wordpress
SQLFILE=`find ${BACKUPDIR}*.sql`
MYSQL_USER=root
MYSQL_PASS=
#meme si pas d'automount, montage manuel
if [ ! -e ${USBKEYDIR} ]
then
mkdir ${USBKEYDIR}
fi
mount ${DEVICE} ${USBKEYDIR}
cp ${BACKUPDIR}*.tar.gz /
tar xzf /*.tar.gz
chown www-data:www-data ${
SRCDIR}
mysql -u${MYSQL_USER} -p${MYSQL_PASS} < ${SQLFILE}
umount ${DEVICE}


Accéder à la page projet

Recent Tweets

Catégories