---------------------------------------------------------------------------------------------------------------------
BACKUPS AND RESTORE
---------------------------------------------------------------------------------------------------------------------
Backup aliases
alias backup-bashaliases='sudo cp -f $HOME/$user/.bash_aliases $HOME/$user/.bash_aliases.backup && echo bash_aliases is now backed up'
Backup bashrc
alias backup-bashrc='sudo cp -f $HOME/$user/.bashrc $HOME/$user/.bashrc.backup && echo bashrc is now backed up'
Backup etc
alias backup-etc='sudo mkisofs -J -r -V "etc.backup" -o $HOME/etc.backup.iso /etc && echo the entire etc directory is now backed up to an iso image'
Restore aliases
alias restore-bashaliases='sudo cp -f bash_aliases.backup $HOME/$user/.bash_aliases && echo bash_aliases is now backed up'
Restore bashrc
alias restore-bashrc='sudo cp -f $HOME/$user/.bashrc.backup $HOME/$user/.bashrc && echo bashrc is now restored'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Backup iptables
alias backup-iptables='sudo iptables-save -c > /$HOME/$user/iptables.rules && sudo iptables-restore < /$HOME/$user/iptables.rules && sudo cp -f /$HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f /$HOME/$user/iptables.rules && sudo cp -f /etc/iptables.rules /etc/iptables.rules.backup && echo iptables.rules is now backed up'
Backup ip6tables
alias backup-ip6tables='sudo ip6tables-save -c > /$HOME/$user/ip6tables.rules && sudo ip6tables-restore < /$HOME/$user/ip6tables.rules && sudo cp -f /$HOME/$user/ip6tables.rules /etc/ip6tables.rules && sudo cp -f /etc/ip6tables.rules /etc/ip6tables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/ip6tables.rules && echo ip6tables.rules is now backed up'
Backup all iptables and ip6tables
alias backup-iptables-all='sudo iptables-save -c > /$HOME/$user/iptables.rules && sudo iptables-restore < /$HOME/$user/iptables.rules && sudo cp -f /$HOME/$user/iptables.rules /etc/iptables.rules && sudo /etc/iptables.rules /etc/iptables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/iptables.rules && sudo ip6tables-save -c > /$HOME/$user/ip6tables.rules && sudo ip6tables-restore < /$HOME/$user/ip6tables.rules && sudo cp -f /$HOME/$user/ip6tables.rules /etc/ip6tables.rules && sudo /etc/ip6tables.rules /etc/ip6tables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/ip6tables.rules && echo iptables and ip6tables.rules are both now backed up'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
restore-iptables
alias restore-iptables='sudo iptables-restore < /etc/iptables.rules.backup && sudo iptables-save -c > $HOME/$user/iptables.rules && sudo iptables-restore < $HOME/$user/iptables.rules && sudo cp -f $HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f $HOME/$user/iptables.rules && echo iptables,rules is now restored'
restore-ip6tables
alias restore-ip6tables='sudo ip6tables-restore < /etc/ip6tables.rules.backup && sudo ip6tables-save -c > $HOME/$user/ip6tables.rules && sudo ip6tables-restore < $HOME/$user/ip6tables.rules && sudo cp -f $HOME/$user/ip6tables.rules /etc/ip6tables.rules && sleep 3s && sudo rm -f $HOME/$user/ip6tables.rules && echo ip6tables,rules is now restored'
backup-iptables-all
alias backup-iptables-all='sudo iptables-restore < /etc/iptables.rules.backup && sudo iptables-save -c > $HOME/$user/iptables.rules && sudo iptables-restore < $HOME/$user/iptables.rules && sudo cp -f $HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f $HOME/$user/iptables.rules && sudo ip6tables-restore < /etc/ip6tables.rules.backup && sudo ip6tables-save -c > $HOME/$user/ip6tables.rules && sudo ip6tables-restore < $HOME/$user/ip6tables.rules && sudo cp -f $HOME/$user/ip6tables.rules /etc/ip6tables.rules && sleep 3s && sudo rm -f $HOME/$user/ip6tables.ruless && echo iptables.rules and ip6tables.rules are now restored'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Backup sources.list
alias backup-source='sudo cp -f /etc/apt/sources.list /etc/apt/sources.list.backup && echo sources.list is now backed up'
Restore sources.list
alias restore-source='sudo cp -f /etc/apt/sources.list.backup /etc/apt/sources.list && echo sources.list is now restored'
Backup gnome
alias backup-gnome='gconftool --dump /apps/panel > $HOME/$user/gnome.backup.xml && echo gnome settings are now backed up to $HOME/$user/gnome-back.xml'
Restore gnome
alias restore-gnome='cd $HOME/$user/Desktop && gconftool --load gnome.backup.xml && echo gnome settings are now restored from gnome-back.xml && $HOME/$user'
Backup xorg
alias backup-xorg='sudo cp -f /etc/X11/xorg.conf /etc/X11/xorg.conf.backup && sudo cp -f /usr/share/xresprobe/xorg.conf /usr/share/xresprobe/xorg.conf.backup && echo xorg is now backed up'
Restore xorg
alias restore-xorg='sudo cp -f /etc/X11/xorg.conf.backup /etc/X11/xorg.conf && sudo cp -f /usr/share/xresprobe/xorg.conf.backup /usr/share/xresprobe/xorg.conf && echo xorg is now restores'
Backup denyhosts
alias backup-denyhosts='sudo cp -f /etc/denyhosts.conf /etc/denyhosts.conf.backup && echo denyhosts is now backed up'
Restore denyhosts
alias restore-denyhosts='sudo cp -f /etc/denyhosts.conf.backup /etc/denyhosts.conf && echo denyhosts is now restored'
Backup logrotate
alias backup-logrotate='sudo cp -f /etc/logrotate.conf /etc/logrotate.conf.backup && echo logrotate.conf is now backed up'
Restore logrotate
alias restore-logrotate='sudo cp -f /etc/logrotate.conf.backup /etc/logrotate.conf && echo logrotate.conf is now restored'
Backup interfaces
alias backup-interfaces='sudo cp -f /etc/network/interfaces /etc/network/interfaces.backup && echo the interfaces configuraion file is now backed up'
Restore interfaces
alias restore-interfaces='sudo cp -f /etc/network/interfaces.backup /etc/network/interfaces && echo the interfaces configuration file is now restored'
Backup samba
alias backup-samba='sudo cp -f /etc/samba/smb.conf /etc/samba/smb.conf.backup && echo smb.conf is now backed up'
Restore samba
alias restore-samba='sudo cp -f /etc/samba/smb.conf.backup /etc/samba/smb.conf && echo smb.conf is now restored'
Backup ssh client
alias backup-ssh-client='sudo cp -f /etc/ssh/ssh_config /etc/ssh/ssh_config.backup && echo ssh_config is now backed up'
Restore ssh client
alias restore-ssh-client='sudo cp -f /etc/ssh/ssh_config.backup /etc/ssh/ssh_config && echo ssh_config is now restored'
Backup syslog
alias backup-syslog='sudo cp -f /etc/syslog.conf /etc/syslog.conf.backup && echo syslog.conf is now backed up'
Restore syslog
alias restore-syslog='sudo cp -f /etc/syslog.conf.backup /etc/syslog.conf && echo syslog.conf is now restored'
---------------------------------------------------------------------------------------------------------------------
THESE ALIASES BELOW RELY ON OTHER ALIASES
---------------------------------------------------------------------------------------------------------------------
=====================================================================================================================
============================= ========================================
=====================================================================================================================
alias backup-all='backup-bashaliases && backup-bashrc && backup-iptables && backup-ip6tables && backup-source && backup-gnome && backup-denyhosts && backup-logrotate && backup-interfaces && backup-samba && backup-ssh-client && backup-syslog && backup-xorg && echo all configuration files have been backed up to their respective directories'
alias backup-archive='cd $HOME/$user/Desktop && tar -cvpf configuration-backups-$HOSTNAME-date +%Y%m%d
"$HOME/$user/.bash_aliases.backup" "$HOME/$user/.bashrc.backup" "/etc/iptables.rules.backup" "/etc/ip6tables.rules.backup" "/etc/apt/sources.list.backup" "$HOME/$user/gnome.backup.xml" "/etc/X11/xorg.conf.backup" "/usr/share/xresprobe/xorg.conf.backup" "/etc/denyhosts.conf.backup" "/etc/logrotate.conf.backup" "/etc/network/interfaces.backup" "/etc/samba/smb.conf.backup" "/etc/ssh/ssh_config.backup" "/etc/syslog.conf.backup" && echo all configuration files have been backed up in their respective directories as well as being copied to an archive on $HOME/$user/Desktop'
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
alias restore-all='restore-bashaliases && restore-bashrc && restore-iptables && restore-ip6tables && restore-source && restore-gnome && restore-denyhosts && restore-logrotate && restore-interfaces && restore-samba && restore-ssh-client && restore-syslog && restore-xorg s&& echo all configuration files have been restored to their respective directories'
alias restore-archive='cd $HOME/$user/Desktop && sudo tar -xvzpf $1 "/etc/iptables.rules.backup" "/etc/ip6tables.rules.backup" "/etc/apt/sources.list.backup" "$HOME/$user/gnome.backup.xml" "/etc/X11/xorg.conf.backup" "/usr/share/xresprobe/xorg.conf.backup" "/etc/denyhosts.conf.backup" "/etc/logrotate.conf.backup" "/etc/network/interfaces.backup" "/etc/samba/smb.conf.backup" "/etc/ssh/ssh_config.backup" "/etc/syslog.conf.backup && echo all configuration files have been restored to their respective directories'
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
This section is for references only for which files are being backed up.
$HOME/$user/.bash_aliases.backup
$HOME/$user/.bashrc.backup
/etc/iptables.rules.backup
/etc/ip6tables.rules.backup
/etc/apt/sources.list.backup
$HOME/$user/gnome.backup.xml
/etc/X11/xorg.conf.backup
/usr/share/xresprobe/xorg.conf.backup
/etc/denyhosts.conf.backup
/etc/logrotate.conf.backup
/etc/network/interfaces.backup
/etc/samba/smb.conf.backup
/etc/ssh/ssh_config.backup
/etc/syslog.conf.backup
=====================================================================================================================
============================= ========================================