Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyXFilesBackupScript

Categories: Tips
<< | Page list | >>

Simple bash script to backup LyX files.

If your script file name is "bak-lyx", from within emelFM2 run "bak-lyx %f" and it should work OK. Essentially, the script will take the selected file, copy it to "./backups" while appending the date and time to the file name.

Warning: it's not rocket-science, so check before use.

The script

#!/bin/bash
# Backup script for LyX files

DIR="./backups"
DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/$1-${DATE}.lyx"

# Check if the dir to store the backups exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi

# Copy file to backup location
cp $1 ${NAME}

# Say you're happy
  echo "File successfully backed up."

Extended script

An extended version of this script can be used to backup just about any file---.lyx, .pdf, .bib, .tex---in an .tar.bz2 archive placed in the ./.backups directory.

#!/bin/bash
# Script for backing-up files into .tar.bz2 archives

DIR="./.backups"
DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/$1-${DATE}.tar.bz2"

# Check if the dir to store the screenshots exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi

# Copy file to backup location
# echo "Backing up:"
tar -cvjf ${NAME} $1

# Say you're happy
  echo ${DATE} "successfully backed up."

Tips

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2009-09-01 15:19 UTC