Results 1 to 7 of 7

Thread: Clearing Cache

  1. #1
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Clearing Cache

    I run a (rsync) script when I shutdown that saves /home and a number of other (personal) data partitions to a backup HD automatically. This is great but I notice that an awful amount of cache files (mainly from /.cache) are also checked/backed up when the saving is taking place. Is there some way I can clear my cache files automatically (Software Centre seems to be a big culprit) before the 'backup' script runs? (Thunderbird is also another 'biggie).

  2. #2
    Join Date
    Aug 2013
    Beans
    4,941

    Re: Clearing Cache

    bleachbit.

  3. #3
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Clearing Cache

    Thanks. My rsync script is in init.d - how do I get (as I shut down down the pc) bleachbit to run automatically before my backup script?

  4. #4
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Clearing Cache

    Why not just use the --exclude option in your rsync command, eg
    Code:
    rsync -r -n -t -p -o -v --progress -h --exclude-from=/full/path/to/excludecache.txt /path/to/source/ /path/to/destination/
    where the excludecache.txt is a simple txt file with a list of folders to exclude. This is mine.
    .adobe/Flash_Player/AssetCache
    .cache
    .local/share/Trash
    .macromedia
    .mozilla/firefox/qn4bdmr0.default/Cache
    .mozilla/firefox/qn4bdmr0.default/Cache.Trash
    .thumbnails
    .thunderbird/cauxhqch.default/Cache
    .thunderbird/cauxhqch.default/Cache.Trash

  5. #5
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Clearing Cache

    This is my backup script (generated by Gadmin rsync):

    #!/bin/sh

    START_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    if [ ! -e '/media/backup' ]; then
    MISSING_PATH=1
    echo -n Missing_destination_path:_ >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    else
    MISSING_PATH=0
    rsync --archive --human-readable --verbose --stats --log-file=/var/log/gadmin-rsync/gadmin-rsync-backup.log.details '/home/dad' '/media/backup'
    fi


    if [ $? -eq 0 ] && [ $MISSING_PATH -eq 0 ]; then
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup successful: Source: [/home/dad] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    else
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup failure: Source: [/home/dad] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    fi

    START_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    if [ ! -e '/media/backup' ]; then
    MISSING_PATH=1
    echo -n Missing_destination_path:_ >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    else
    MISSING_PATH=0
    rsync --archive --human-readable --verbose --stats --log-file=/var/log/gadmin-rsync/gadmin-rsync-backup.log.details '/media/store' '/media/backup'
    fi


    if [ $? -eq 0 ] && [ $MISSING_PATH -eq 0 ]; then
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup successful: Source: [/media/store] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    else
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup failure: Source: [/media/store] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    fi



    how would I include your line(?) - add this to the bottom of the page:

    if [ $? -eq 0 ] && [ $MISSING_PATH -eq 0 ]; then
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup successful: Source: [/media/store] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    else
    STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
    echo "$START_TIME $STOP_TIME Backup failure: Source: [/media/store] Destination: [/media/backup]" >> /var/log/gadmin-rsync/gadmin-rsync-backup.log
    fi


    rsync -r -n -t -p -o -v --progress -h --exclude-from=/full/path/to/excludecache.txt /home/dad/ /media/backup/dad/

    fi

  6. #6
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Clearing Cache

    I think you would just need to add the option
    Code:
    --exclude-from=/full/path/to/excludecache.txt
    to your full rsync execution commands in the top and the third stanza of that script, eg,
    Code:
    rsync --archive --human-readable --verbose --stats  --log-file=/var/log/gadmin-rsync/gadmin-rsync-backup.log.details  '/media/store' '/media/backup'
    so it becomes
    Code:
    rsync --archive --human-readable --verbose --exclude-from=/full/path/to/excludecache.txt --stats  --log-file=/var/log/gadmin-rsync/gadmin-rsync-backup.log.details  '/media/store' '/media/backup'
    Try it out to see if that works as I think it should. I have never used nor have any knowledge of Gadmin rsync, so I may be totally wrong about all of this.

  7. #7
    Join Date
    Sep 2009
    Location
    London
    Beans
    1,126

    Re: Clearing Cache

    did you get this to work? And if you did, would you share your script and how to use it?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •