Xu Xiaodong avatar Xu Xiaodong committed 7419321

initial commit

Comments (0)

Files changed (3)

+#!/usr/bin/env perl
+#
+# name:      baksql.pl, backup mysql database
+# author:    Xu Xiaodong <xxdlhy@gmail.com>
+# license:   GPL
+# created:   2011 Feb 26
+# modified:  2011 May 08
+#
+
+use strict;
+use warnings;
+
+our $cwd = '';
+
+sub backup_sql {
+  my $user = '';
+  my $pass = '';
+
+  my $db_name = '';
+  chomp( my $date = `date +%Y%m%d%H%M%S` );
+  my $sql_name = $date . '.sql';
+  my $bak_name = $sql_name . '.tar.gz';
+
+  my $bak_cmd
+    = "mysqldump --add-drop-table --user=$user --password=$pass $db_name > $sql_name";
+  my $tar_cmd = "tar czf $bak_name $sql_name";
+
+  chdir $cwd;
+  system $bak_cmd;
+  system $tar_cmd;
+  unlink $sql_name;
+}
+
+sub delete_tar {
+  chdir $cwd;
+
+  opendir my ($dir_fh), $cwd or die "Can't open $cwd: $!\n";
+  my @files = grep { /\.tar.gz$/ } readdir $dir_fh;
+  closedir $dir_fh;
+
+  for my $file (@files) {
+    unlink $file if -M $file > 5;
+  }
+}
+
+sub run {
+  backup_sql();
+  delete_tar();
+}
+
+run() unless caller;
+#!/usr/bin/env perl
+#
+# name:      runsrv.pl, run server
+# author:    Xu Xiaodong <xxdlhy@gmail.com>
+# license:   GPL
+# created:   2010 Jul  5
+# modified:  2011 May 08
+#
+
+use 5.010;
+use strict;
+use warnings;
+
+my @tasks = qw(nginx php5-cgi mysql);
+my $path  = "/etc/init.d/";
+
+foreach my $task (@tasks) {
+  chomp( my $pid = qx(pgrep -o $task) );
+  my $bin = $path . $task;
+
+  unless ($pid) {
+    system $bin, "start";
+  }
+  else {
+    say "[OK] \U$task\E is running.";
+  }
+}
+#!/bin/bash
+# author:    Xu Xiaodong <xxdlhy@gmail.com>
+# modified:  2011 May 08
+#
+
+/usr/bin/rsync -avl --delete --stats --progress \
+  --exclude 'wp-content/cache/*' \
+  -e ssh user@000.000.000.0:/home/www/linuxtoy.org/public /home/xiaodong/sites/linuxtoy.org/
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.