User talk:Gen2ly/System backup and reinstall

From ArchWiki
< User talk:Gen2ly
Revision as of 14:59, 12 April 2013 by Kynikos (Talk | contribs) (restoring here the script deleted with

Jump to: navigation, search


Would it make sense to remove references to Yaourt and include a more generic solution for installing packages from the AUR?

Or would it be better to add different sections for different AUR helpers? ("If you use Yaourt...", "If you use Packer...", "If you use aurget...") - drcouzelis, 12 March 2010

I prefer to simply write "Install X from the AUR." -- pointone 23:54, 12 March 2010 (EST)
I prefer this too, but still I think that most users are favorable to Yaourt. It is the best tool for those new to Arch and by far the most complete. This will probably change sometime in the ?near? future but until then I think giving the reader the most prevalent option is the wisest solution. Hummm, maybe I'm old fashioned :).
--Gen2ly 05:28, 15 March 2010 (EDT)

Backup Script

[Restoring here the script deleted with without an appropriate discussion. -- Kynikos (talk) 14:59, 12 April 2013 (UTC)]

This backup script has the ability to add to the include and exclude files and the ability to backup the configurations. The usage is:

 bckcfg <i|e|n|c> - backup configurations
  i - add to the include list a file or folder
  e - add to the exclude list a file or folder or regexp pattern
  n - add note
  c - create backup

For example to add to the include file:

bckcfg i /etc/rc.conf

And to add to the exclude file:

bckcfg e .thumbnails/

The script is able to detect the full path so writing a relative or partial path is acceptable.

To backup, this script names your backup by several definable variables, removes old backups if desired, then backs up the configurations. The include and exclude files are placed in the same directory as the backup script.

# Backup configurations

# Backup destination directory

# Backup name
comp="${HOSTNAME}"  # Computer name
dist="arch"         # Distro
date="$(date "+%F")"

# Include and exclude file locations

scrp_help () {
echo " ${0##*/} <i|e|n|c> - backup configurations
  i - add to the include list a file or folder
  e - add to the exclude list a file or folder or regexp pattern
  n - add note
  c - create backup"

del_old_bckps () {
if [[ -n "$(find "$bckp_dest" -mtime +30)" ]]; then
  find "$bckp_dest" -name "$distro-$type-*" -mtime +30 -exec rm {} \
  \; && echo " Deleted backups older than one month."

case $1 in
  # Add to include list file or folder
  i ) shift
      for f in "$@"; do
        # Check if selection(s) exist
        if [ ! -e "$f" ]; then
          echo " File \""$f"\" does not exist."
        # Append file/folder to include list
        full_path=$(readlink -f "$f")
        echo "$full_path" >> "$incl_file" && \
        echo " Added \""$f"\" to ${0##*/} include file."
      # Sort entries
      sort -u "$incl_file" -o "$incl_file" ;;
  # Add to exclude list file, folder, or regexp pattern
  e ) shift
      echo " * \"${0##*/}\" doesn't check if patch is correct because the exclude file can contain regexps.  Be sure the path is correct (e.g. '/mnt/win/*')" | fmt -c -u -w 80
      read -p " Add \""$@"\" to ${0##*/} exclude file? (y/n): " add_exclude
      if [[ "$add_exclude" == [Yy] ]]; then
        echo "$@" >> "$excl_file" && \
        echo " Added \""$@"\" to ${0##*/} exclude file."
        echo " Error: \""$@"\" not added."
      fi ;;
  # Add to note file
  n ) shift
      echo ""$date"-"$(date "+%r")": "$@"" >> "$note_file" && \
      echo " Added string to \""$note_file"\"." ;;
  # Create backup
  c ) # Check if backup directory exists
      if [ ! -d "$bckp_dest" ]; then
        echo " Directory \""$bckp_dest"\" does not exist."
      # Delete old backups
      # Backup configurations
      sudo tar --exclude-from=$excl_file --files-from=$incl_file -c --xz -f $bckp_file ;;
  * ) # Display usage if no parameters give
      scrp_help ;;